From de954cac909d1ec0702a5ba2b0eb1823f999043d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 10 Sep 2022 08:17:01 +0000 Subject: [PATCH] www: viewdiff: use return value for diff_hunk 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index f16c7229..349ffec8 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -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(@@ {Q}$n">$ca); + my $x = qq(@@ {Q}$n">$ca); ($n) = ($cb =~ /^\+([0-9]+)/); $n = defined($n) ? "#n$n" : ''; - $$dst .= qq( {Q}$n">$cb @@); + $x .= qq( {Q}$n">$cb @@); } else { - $$dst .= "@@ $ca $cb @@"; + "@@ $ca $cb @@"; } } @@ -229,7 +229,7 @@ sub flush_diff ($$) { $after .= $s; } elsif ($s =~ s/\A@@ (\S+) (\S+) @@//) { $$dst .= qq(); - diff_hunk($dst, $dctx, $1, $2); + $$dst .= diff_hunk($dctx, $1, $2); $$dst .= $linkify->to_html($s); $$dst .= ''; } elsif ($s =~ /\A\+/) { -- 2.48.1