From: Markus Elfring <Markus.Elfring@web.de>
To: git@vger.kernel.org
Cc: "Gábor Szeder" <szeder.dev@gmail.com>
Subject: [PATCH] coccinelle: merge eight rules from strbuf.cocci
Date: Tue, 12 Nov 2019 17:55:40 +0100 [thread overview]
Message-ID: <31d2b9c8-31ec-4921-d38d-12712de819a7@web.de> (raw)
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
reply other threads:[~2019-11-12 16:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31d2b9c8-31ec-4921-d38d-12712de819a7@web.de \
--to=markus.elfring@web.de \
--cc=git@vger.kernel.org \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.