Skip to contentSkip to conversation

coccinelle: misc: struct_size: drop unneeded parentheses

PATCH New Sang-Heon Jeon 1 participant 1 message Aug 24 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coccinelle: misc: struct_size: drop unneeded parentheses

The outer parentheses and the single-branch disjunction don't matter when just matching and reporting a line. Eliminating them reduces the complexity of the pattern to match and gives a performance improvement in the non-patch cases, like the previous minmax change.

---
 scripts/coccinelle/misc/struct_size.cocci | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
scripts/coccinelle/misc/struct_size.cocci +2 -6
index 9b02c37438e4..406884d68d43 100644
@@ -29,9 +29,7 @@ f
 expression E1, E2;
 identifier m;
 @@
-(
-* (sizeof(*E1) + (E2 * sizeof(*E1->m)))
-)
+* sizeof(*E1) + (E2 * sizeof(*E1->m))
 
 //----------------------------------------------------------
 //  For patch mode
@@ -55,9 +53,7 @@ expression E1, E2;
 identifier m;
 position p;
 @@
-(
- (sizeof(*E1)@p + (E2 * sizeof(*E1->m)))
-)
+ sizeof(*E1)@p + (E2 * sizeof(*E1->m))
 
 @script:python depends on org@
 p << r.p;
Signature · 1 line
2.43.0