Re: [PATCH 3/3] gitweb: Few doublequoted strings cleanups
- From
Junio C Hamano <junkio@cox.net>
- Date
- Apr 3, 2007, 20:20 UTC
- Message-ID
- <7vlkh9w6pa.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <200704012223.00087.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Replace a few doublequoted strings by theirs singlequoted equivalent, > lose doublequotes around variable in string containing only > of a variable name, use '' consistently as an empty string (and not > sometimes as "").
Why? I do not in particular like a micro-cleanup like this (it seems more of personal taste than cleanup).
> - } elsif ($char eq "\\") {
> + } elsif ($char eq '\\') {
> $diff_class = " incomplete";
> }Especially this makes a shell scripter think twice before realizing that this is Perl and a backslash expands inside single quotes. In other words, I find that the former is easier to read.
Show 6 quoted lines
> @@ -1052,7 +1052,7 @@ sub git_get_projects_list {
> my $dir = $projects_list . ($filter ? "/$filter" : '');
> # remove the trailing "/"
> $dir =~ s!/+$!!;
> - my $pfxlen = length("$dir");
> + my $pfxlen = length($dir);On the other hand, I think this makes the code easier to read.
> @@ -1261,7 +1261,7 @@ sub parse_tag {
> } elsif ($line =~ m/--BEGIN/) {
> push @comment, $line;
> last;One thing I noticed is that we seem to have needless 'm' as in the above m/--BEGIN/ in some places. My preferences are (this falls within "personal taste" category):
* Unless the pattern has slashes, drop 'm' for match, always use '|' as the delimiter for substitution s/A/B;
* If the pattern has slashes, consistently use the same alternate letter as the delimiter (gitweb seems to use '!').
Show 8 quoted lines
> @@ -3616,7 +3616,7 @@ sub git_snapshot {
>
> print $cgi->header(
> -type => "application/$ctype",
> - -content_disposition => 'inline; filename="' . "$filename" . '"',
> + -content_disposition => 'inline; filename="' . $filename . '"',
> -status => '200 OK');
> Wouldn't it be easier to read if we did
"inline; filename=\"$filename\""
instead?