]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewdiff: use autovivification for long_path hash
authorEric Wong <e@yhbt.net>
Sat, 25 Jan 2020 04:45:09 +0000 (04:45 +0000)
committerEric Wong <e@yhbt.net>
Mon, 27 Jan 2020 02:59:09 +0000 (02:59 +0000)
No sense in wasting code to do something the interpreter
already does for us.

lib/PublicInbox/ViewDiff.pm

index ff7d85f55649670e49649d84937ebb3e1a460dd5..ece95f4c2b9b318de5ccc02db8e53bdb27e99bc5 100644 (file)
@@ -92,8 +92,7 @@ sub anchor0 ($$$$$) {
 
        # long filenames will require us to walk backwards in anchor1
        if ($fn =~ s!\A\.\.\./?!!) {
 
        # long filenames will require us to walk backwards in anchor1
        if ($fn =~ s!\A\.\.\./?!!) {
-               my $lp = $ctx->{-long_path} ||= {};
-               $lp->{$fn} = qr/\Q$fn\E\z/s;
+               $ctx->{-long_path}->{$fn} = qr/\Q$fn\E\z/s;
        }
 
        if (my $attr = to_attr($ctx->{-apfx}.$fn)) {
        }
 
        if (my $attr = to_attr($ctx->{-apfx}.$fn)) {