From: Simon Ruderich Date: Mon, 9 Apr 2012 16:18:33 +0000 (+0200) Subject: Use references to flag arrays to reduce code duplication. X-Git-Tag: 0.01~28 X-Git-Url: https://ruderich.org/simon/gitweb/?p=blhc%2Fblhc.git;a=commitdiff_plain;h=273f7a78980493d607823c32e364e4efe901c879 Use references to flag arrays to reduce code duplication. --- diff --git a/bin/blhc b/bin/blhc index 10b39f3..e17c377 100755 --- a/bin/blhc +++ b/bin/blhc @@ -188,6 +188,26 @@ my @def_ldflags_pic = ( '-fpic', '-shared', ); +# References to all flags checked by the parser. +my @flag_refs = ( + \@def_cflags, + \@def_cflags_format, + \@def_cflags_fortify, + \@def_cflags_stack, + \@def_cflags_pie, + \@def_cxxflags, + \@def_cppflags, + \@def_cppflags_fortify, + \@def_ldflags, + \@def_ldflags_relro, + \@def_ldflags_bindnow, +); +# References to all used flags. +my @flag_refs_all = ( + @flag_refs, + \@def_ldflags_pie, + \@def_ldflags_pic, +); # Renaming rules for the output so the regex parts are not visible. Also # stores string values of flag regexps above, see compile_flag_regexp(). my %flag_renames = ( @@ -461,19 +481,9 @@ if ($option_all) { # Precompile all flag regexps. any_flags_used(), all_flags_used() get a lot # faster with this. -@def_cflags = compile_flag_regexp(\%flag_renames, @def_cflags); -@def_cflags_format = compile_flag_regexp(\%flag_renames, @def_cflags_format); -@def_cflags_fortify = compile_flag_regexp(\%flag_renames, @def_cflags_fortify); -@def_cflags_stack = compile_flag_regexp(\%flag_renames, @def_cflags_stack); -@def_cflags_pie = compile_flag_regexp(\%flag_renames, @def_cflags_pie); -@def_cxxflags = compile_flag_regexp(\%flag_renames, @def_cxxflags); -@def_cppflags = compile_flag_regexp(\%flag_renames, @def_cppflags); -@def_cppflags_fortify = compile_flag_regexp(\%flag_renames, @def_cppflags_fortify); -@def_ldflags = compile_flag_regexp(\%flag_renames, @def_ldflags); -@def_ldflags_relro = compile_flag_regexp(\%flag_renames, @def_ldflags_relro); -@def_ldflags_bindnow = compile_flag_regexp(\%flag_renames, @def_ldflags_bindnow); -@def_ldflags_pie = compile_flag_regexp(\%flag_renames, @def_ldflags_pie); -@def_ldflags_pic = compile_flag_regexp(\%flag_renames, @def_ldflags_pic); +foreach my $flags (@flag_refs_all) { + @{$flags} = compile_flag_regexp(\%flag_renames, @{$flags}); +} # Final exit code. my $exit = 0;