]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewdiff: diff_hunk: shorten conditionals, slightly
authorEric Wong <e@80x24.org>
Sat, 10 Sep 2022 08:17:15 +0000 (08:17 +0000)
committerEric Wong <e@80x24.org>
Sat, 10 Sep 2022 19:50:45 +0000 (19:50 +0000)
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

lib/PublicInbox/ViewDiff.pm

index b9194ed46030da58256fb3bed5bbf9e1220070e9..076aa1af6546c15fc209bc3cfcf0cf7cd826c3eb 100644 (file)
@@ -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(@@ <a\nhref="$spfx$oid_a/s/$dctx->{Q}$n">$ca</a>);
 
-               ($n) = ($cb =~ /^\+([0-9]+)/);
-               $n = defined($n) ? "#n$n" : '';
+               $n = ($cb =~ /^\+([0-9]+)/) ? "#n$1" : '';
                $x .= qq( <a\nhref="$spfx$oid_b/s/$dctx->{Q}$n">$cb</a> @@);
        } else {
                "@@ $ca $cb @@";