]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: remove some intermediate arrays
authorEric Wong <e@80x24.org>
Sat, 20 Aug 2022 08:01:32 +0000 (08:01 +0000)
committerEric Wong <e@80x24.org>
Sat, 20 Aug 2022 18:30:55 +0000 (18:30 +0000)
We can assign arrays directly without `[]' creating an extra
immortal pad allocation.

lib/PublicInbox/IMAP.pm

index 0a65d87cb009f790fe114ce175a0bff639943f18..1f65aa650e2954e2a43b8549fabf33c829c00f41 100644 (file)
@@ -1005,7 +1005,7 @@ sub fetch_compile ($) {
        # stabilize partial order for consistency and ease-of-debugging:
        if (scalar keys %partial) {
                $need |= NEED_BLOB;
-               $r[2] = [ map { [ $_, @{$partial{$_}} ] } sort keys %partial ];
+               @{$r[2]} = map { [ $_, @{$partial{$_}} ] } sort keys %partial;
        }
 
        push @op, $OP_EML_NEW if ($need & (EML_HDR|EML_BDY));
@@ -1028,7 +1028,7 @@ sub fetch_compile ($) {
 
        # r[1] = [ $key1, $cb1, $key2, $cb2, ... ]
        use sort 'stable'; # makes output more consistent
-       $r[1] = [ map { ($_->[2], $_->[1]) } sort { $a->[0] <=> $b->[0] } @op ];
+       @{$r[1]} = map { ($_->[2], $_->[1]) } sort { $a->[0] <=> $b->[0] } @op;
        @r;
 }