coccinelle: misc: minmax: drop unneeded parentheses
authorJulia Lawall <Julia.Lawall@inria.fr>
Sun, 26 Jul 2026 14:01:38 +0000 (16:01 +0200)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sun, 23 Aug 2026 20:12:09 +0000 (22:12 +0200)
The outer parentheses don't matter when just matching an returning a line.
Eliminating them reduces the complexity of the pattern to match and
gives a small performance improvement in the non-patch cases.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
scripts/coccinelle/misc/minmax.cocci

index 93c074b..905dd22 100644 (file)
@@ -22,14 +22,14 @@ expression E1, E2, E3, E4;
 binary operator cmp = {>, >=};
 @@
 
-       (E1 cmp E2 ? E3 : E4)
+       E1 cmp E2 ? E3 : E4
 
 @min_candidate@
 expression E1, E2, E3, E4;
 binary operator cmp = {<, <=};
 @@
 
-       (E1 cmp E2 ? E3 : E4)
+       E1 cmp E2 ? E3 : E4
 
 @rmax depends on !patch && max_candidate@
 identifier func;
@@ -41,7 +41,7 @@ position p;
 func(...)
 {
        <...
-*      ((x) cmp@p (y) ? (x) : (y))
+*      (x) cmp@p (y) ? (x) : (y)
        ...>
 }
 
@@ -89,7 +89,7 @@ position p != errcode.p;
 func(...)
 {
        <...
-*      ((x) cmp@p (y) ? (x) : (y))
+*      (x) cmp@p (y) ? (x) : (y)
        ...>
 }