From: Michał Kiedrowicz Date: Thu, 29 Mar 2012 18:04:20 GMT Subject: [PATCH] gitweb: Use descriptive names in esc_html_hl_regions() Message-ID: <1333044260-31278-1-git-send-email-michal.kiedrowicz@gmail.com> In-Reply-To: <201203241958.23835.jnareb@gmail.com> The $s->[0] and $s->[1] variables look a bit cryptic. Let's rename them to $beg and $end so that it's clear what they do. Signed-off-by: Michał Kiedrowicz --- > P.S. I wonder if it wouldn't be better if we created and used loop-local > variables with descriptive names, e.g. > > my ($beg, $end) = @$s; > > and use $beg in place of $s->[0] and $end in place of $s->[1], which are > a bit cryptic. > > This of course doesn't affect this patch. Something like this? (patch not based on this series, may be applied independently). gitweb/gitweb.perl | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index a8b5fad..a3754ff 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1738,12 +1738,14 @@ sub esc_html_hl_regions { my $pos = 0; for my $s (@sel) { - $out .= esc_html(substr($str, $pos, $s->[0] - $pos)) - if ($s->[0] - $pos > 0); + my ($beg, $end) = @$s; + + $out .= esc_html(substr($str, $pos, $beg - $pos)) + if ($beg - $pos > 0); $out .= $cgi->span({-class => $css_class}, - esc_html(substr($str, $s->[0], $s->[1] - $s->[0]))); + esc_html(substr($str, $beg, $end - $beg))); - $pos = $s->[1]; + $pos = $end; } $out .= esc_html(substr($str, $pos)) if ($pos < length($str)); -- 1.7.8.4