git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] coccinelle: merge eight rules from strbuf.cocci
@ 2019-11-12 16:55 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2019-11-12 16:55 UTC (permalink / raw)
  To: git; +Cc: Gábor Szeder

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 12 Nov 2019 17:50:13 +0100

This script contained transformation rules for the semantic patch language
which used similar code.
Combine these rules by using two SmPL disjunctions so that the run time
characteristics can be nicer because of common usage of a few metavariables.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 contrib/coccinelle/strbuf.cocci | 49 +++++++++++----------------------
 1 file changed, 16 insertions(+), 33 deletions(-)

diff --git a/contrib/coccinelle/strbuf.cocci b/contrib/coccinelle/strbuf.cocci
index d9ada69b43..b66c9bf8e3 100644
--- a/contrib/coccinelle/strbuf.cocci
+++ b/contrib/coccinelle/strbuf.cocci
@@ -1,7 +1,11 @@
-@ strbuf_addf_with_format_only @
+@replacement1@
 expression E;
 constant fmt !~ "%";
+struct strbuf SB;
+struct strbuf *SBP;
+format F =~ "s";
 @@
+(
 - strbuf_addf
 + strbuf_addstr
   (E,
@@ -11,52 +15,31 @@ constant fmt !~ "%";
   _(fmt)
 )
   );
-
-@@
-expression E;
-struct strbuf SB;
-format F =~ "s";
-@@
+|
 - strbuf_addf(E, "%@F@", SB.buf);
 + strbuf_addbuf(E, &SB);
-
-@@
-expression E;
-struct strbuf *SBP;
-format F =~ "s";
-@@
+|
 - strbuf_addf(E, "%@F@", SBP->buf);
 + strbuf_addbuf(E, SBP);
-
-@@
-expression E;
-struct strbuf SB;
-@@
+|
 - strbuf_addstr(E, SB.buf);
 + strbuf_addbuf(E, &SB);
-
-@@
-expression E;
-struct strbuf *SBP;
-@@
+|
 - strbuf_addstr(E, SBP->buf);
 + strbuf_addbuf(E, SBP);
+)

-@@
-expression E1, E2;
+@replacement2@
+expression E1, E2, E3;
 format F =~ "s";
 @@
+(
 - strbuf_addf(E1, "%@F@", E2);
 + strbuf_addstr(E1, E2);
-
-@@
-expression E1, E2, E3;
-@@
+|
 - strbuf_addstr(E1, find_unique_abbrev(E2, E3));
 + strbuf_add_unique_abbrev(E1, E2, E3);
-
-@@
-expression E1, E2;
-@@
+|
 - strbuf_addstr(E1, real_path(E2));
 + strbuf_add_real_path(E1, E2);
+)
--
2.24.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-12 16:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 16:55 [PATCH] coccinelle: merge eight rules from strbuf.cocci Markus Elfring

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).