* [committed] gen-pass-instances.awk: Use early-out in handle_line
@ 2015-11-12 8:13 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2015-11-12 8:13 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 136 bytes --]
Hi,
this patch restructures handle_line in gen-pass-instances.awk to use an
early-out.
Committed to trunk as trivial.
Thanks,
- Tom
[-- Attachment #2: 0004-gen-pass-instances.awk-Use-early-out-in-handle_line.patch --]
[-- Type: text/x-patch, Size: 1679 bytes --]
gen-pass-instances.awk: Use early-out in handle_line
2015-11-11 Tom de Vries <tom@codesourcery.com>
* gen-pass-instances.awk (handle_line): Restructure using early-out.
---
gcc/gen-pass-instances.awk | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/gcc/gen-pass-instances.awk b/gcc/gen-pass-instances.awk
index 9eaac65..27e7a98 100644
--- a/gcc/gen-pass-instances.awk
+++ b/gcc/gen-pass-instances.awk
@@ -41,25 +41,27 @@ BEGIN {
function handle_line()
{
line = $0;
+
where = match(line, /NEXT_PASS \((.+)\)/);
- if (where != 0)
+ if (where == 0)
{
- len_of_start = length("NEXT_PASS (");
- len_of_end = length(")");
- len_of_pass_name = RLENGTH - (len_of_start + len_of_end);
- pass_starts_at = where + len_of_start;
- pass_name = substr(line, pass_starts_at, len_of_pass_name);
- if (pass_name in pass_counts)
- pass_counts[pass_name]++;
- else
- pass_counts[pass_name] = 1;
- printf "%s, %s%s\n",
- substr(line, 1, pass_starts_at + len_of_pass_name - 1),
- pass_counts[pass_name],
- substr(line, pass_starts_at + len_of_pass_name);
- } else {
print line;
+ return;
}
+
+ len_of_start = length("NEXT_PASS (");
+ len_of_end = length(")");
+ len_of_pass_name = RLENGTH - (len_of_start + len_of_end);
+ pass_starts_at = where + len_of_start;
+ pass_name = substr(line, pass_starts_at, len_of_pass_name);
+ if (pass_name in pass_counts)
+ pass_counts[pass_name]++;
+ else
+ pass_counts[pass_name] = 1;
+ printf "%s, %s%s\n",
+ substr(line, 1, pass_starts_at + len_of_pass_name - 1),
+ pass_counts[pass_name],
+ substr(line, pass_starts_at + len_of_pass_name);
}
{ handle_line() }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-11-12 8:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 8:13 [committed] gen-pass-instances.awk: Use early-out in handle_line Tom de Vries
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).