]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Use block form of map/grep in a few cases more
authorJakub Narebski <redacted>
Sun, 10 May 2009 00:40:37 +0000 (02:40 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:38 +0000 (00:50 -0400)
Use block form of 'grep' i.e. 'grep {BLOCK} LIST' rather than
'grep(EXPR, LIST)' in filter_snapshot_fmts subroutine.  This makes
code more readable, as expression is rather long, and statement above
there is 'map' with very similar expression also in the block form.

Remove unnecessary and misleading parentheses around block form 'map'
arguments in quote_command subroutine.

The inner "map" in format_snapshot_links was left alone, as it is not
clear whether adding parentheses or changing it into block form would
improve readibility and clarity of this code.

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 9f0e84e04b12e1a67599bb363cc3988bca3bfc12c5161441d98613e94df6841e..cb821b5b963b391db4dcfce5927fd6863df1eebceed15b9d0926ff70fdd95960 100755 (executable)
@@ -459,8 +459,8 @@ sub filter_snapshot_fmts {
        @fmts = map {
                exists $known_snapshot_format_aliases{$_} ?
                       $known_snapshot_format_aliases{$_} : $_} @fmts;
        @fmts = map {
                exists $known_snapshot_format_aliases{$_} ?
                       $known_snapshot_format_aliases{$_} : $_} @fmts;
-       @fmts = grep(exists $known_snapshot_formats{$_}, @fmts);
-
+       @fmts = grep {
+               exists $known_snapshot_formats{$_} } @fmts;
 }
 
 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
 }
 
 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
@@ -1839,7 +1839,7 @@ sub git_cmd {
 # Try to avoid using this function wherever possible.
 sub quote_command {
        return join(' ',
 # Try to avoid using this function wherever possible.
 sub quote_command {
        return join(' ',
-                   map( { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ ));
+               map { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ );
 }
 
 # get HEAD ref of given project as hash
 }
 
 # get HEAD ref of given project as hash
This page took 0.245094 seconds and 4 git commands to generate.