From d2616f3df605bcb301c552bb5ce69798536d8257 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 12 Nov 2015 07:31:01 +0000 Subject: [PATCH] gen-pass-instances.awk: Use early-out in handle_line 2015-11-12 Tom de Vries * gen-pass-instances.awk (handle_line): Restructure using early-out. From-SVN: r230208 --- gcc/ChangeLog | 4 ++++ gcc/gen-pass-instances.awk | 32 +++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86152a64fe7..5ed0f411c0b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2015-11-12 Tom de Vries + + * gen-pass-instances.awk (handle_line): Restructure using early-out. + 2015-11-12 Tom de Vries * gen-pass-instances.awk (handle_line): Unify semicolon use. diff --git a/gcc/gen-pass-instances.awk b/gcc/gen-pass-instances.awk index 9eaac65ae5e..27e7a98a8d5 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() } -- 2.30.2