From: Eric Wong Date: Sat, 10 Sep 2022 08:17:15 +0000 (+0000) Subject: viewdiff: diff_hunk: shorten conditionals, slightly X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=03673adef5a74f7ebd6be960187e5e8592779900;p=public-inbox.git viewdiff: diff_hunk: shorten conditionals, slightly I'm not sure if Devel::Size::total_size can be trusted due to the regexps and crashes[1], but when it works, it's showing around a 900 byte size reduction, too. [1] https://rt.cpan.org/Public/Bug/Display.html?id=96421 --- diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index b9194ed4..076aa1af 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -51,13 +51,10 @@ sub diff_hunk ($$$) { 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" : ''; - + my $n = ($ca =~ /^-([0-9]+)/) ? "#n$1" : ''; my $x = qq(@@ {Q}$n">$ca); - ($n) = ($cb =~ /^\+([0-9]+)/); - $n = defined($n) ? "#n$n" : ''; + $n = ($cb =~ /^\+([0-9]+)/) ? "#n$1" : ''; $x .= qq( {Q}$n">$cb @@); } else { "@@ $ca $cb @@";