gitweb: Use descriptive names in esc_html_hl_regions()
The $s->[0] and $s->[1] variables look a bit cryptic. Let's rename them to $begin and $end so that it's clear what they do. Suggested-by: Jakub Narębski <jnareb@gmail.com> Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michał Kiedrowicz committed
Apr 11, 2012 at 23:18 UTC
ce61fb968f9b86f5d889eeb7b80da8ec3d6bfb9b
1 file changed
+8
-5
gitweb/gitweb.perl
+8
-5
@@ -1738,12 +1738,15 @@ sub esc_html_hl_regions {
1738
my $pos = 0;
1739
1740
for my $s (@sel) {
1741
- $out .= esc_html(substr($str, $pos, $s->[0] - $pos))
1742
- if ($s->[0] - $pos > 0);
1743
- $out .= $cgi->span({-class => $css_class},
1744
- esc_html(substr($str, $s->[0], $s->[1] - $s->[0])));
1741
+ my ($begin, $end) = @$s;
1742
1746
- $pos = $s->[1];
1743
+ my $escaped = esc_html(substr($str, $begin, $end - $begin));
1744
+
1745
+ $out .= esc_html(substr($str, $pos, $begin - $pos))
1746
+ if ($begin - $pos > 0);
1747
+ $out .= $cgi->span({-class => $css_class}, $escaped);
1748
+
1749
+ $pos = $end;
1750
}
1751
$out .= esc_html(substr($str, $pos))
1752
if ($pos < length($str));