From: Simon Ruderich Date: Wed, 14 Aug 2013 13:17:29 +0000 (+0200) Subject: Reduce duplication in compile_flag_regexp(). X-Git-Tag: 0.05~24 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=19728cda633b5ab8e207a95bb22c5b526bd239c4;p=blhc%2Fblhc.git Reduce duplication in compile_flag_regexp(). --- diff --git a/bin/blhc b/bin/blhc index 3abb979..c7457d2 100755 --- a/bin/blhc +++ b/bin/blhc @@ -500,15 +500,17 @@ sub compile_flag_regexp { my @result = (); foreach my $flag (@flags) { + # Compile flag regexp for faster execution. + my $regex = qr/\s$flag(?:\s|\\)/; + # Store flag name in replacement string for correct flags in messages # with qr//ed flag regexps. - $flag_renames_ref->{qr/\s$flag(?:\s|\\)/} + $flag_renames_ref->{$regex} = (exists $flag_renames_ref->{$flag}) ? $flag_renames_ref->{$flag} : $flag; - # Compile flag regexp for faster execution. - push @result, qr/\s$flag(?:\s|\\)/; + push @result, $regex; } return @result; }