]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: viewdiff: use return value for diff_hunk
authorEric Wong <e@80x24.org>
Sat, 10 Sep 2022 08:17:01 +0000 (08:17 +0000)
committerEric Wong <e@80x24.org>
Sat, 10 Sep 2022 19:50:31 +0000 (19:50 +0000)
It's only a short string, so there's not much copy overhead,
and it'll make future changes easier to reason about.

lib/PublicInbox/ViewDiff.pm

index f16c72297926529beadc416a1da43b6d656d0825..349ffec8a0d4b52568316acac77d7cfc3e18129a 100644 (file)
@@ -46,21 +46,21 @@ sub uri_escape_path {
 }
 
 # link to line numbers in blobs
-sub diff_hunk ($$$$) {
-       my ($dst, $dctx, $ca, $cb) = @_;
+sub diff_hunk ($$$) {
+       my ($dctx, $ca, $cb) = @_;
        my ($oid_a, $oid_b, $spfx) = @$dctx{qw(oid_a oid_b spfx)};
 
        if (defined($spfx) && defined($oid_a) && defined($oid_b)) {
                my ($n) = ($ca =~ /^-([0-9]+)/);
                $n = defined($n) ? "#n$n" : '';
 
-               $$dst .= qq(@@ <a\nhref="$spfx$oid_a/s/$dctx->{Q}$n">$ca</a>);
+               my $x = qq(@@ <a\nhref="$spfx$oid_a/s/$dctx->{Q}$n">$ca</a>);
 
                ($n) = ($cb =~ /^\+([0-9]+)/);
                $n = defined($n) ? "#n$n" : '';
-               $$dst .= qq( <a\nhref="$spfx$oid_b/s/$dctx->{Q}$n">$cb</a> @@);
+               $x .= qq( <a\nhref="$spfx$oid_b/s/$dctx->{Q}$n">$cb</a> @@);
        } else {
-               $$dst .= "@@ $ca $cb @@";
+               "@@ $ca $cb @@";
        }
 }
 
@@ -229,7 +229,7 @@ sub flush_diff ($$) {
                                        $after .= $s;
                                } elsif ($s =~ s/\A@@ (\S+) (\S+) @@//) {
                                        $$dst .= qq(<span\nclass="hunk">);
-                                       diff_hunk($dst, $dctx, $1, $2);
+                                       $$dst .= diff_hunk($dctx, $1, $2);
                                        $$dst .= $linkify->to_html($s);
                                        $$dst .= '</span>';
                                } elsif ($s =~ /\A\+/) {