From: Eric Wong <e@80x24.org>
Date: Sat, 20 Aug 2022 08:01:32 +0000 (+0000)
Subject: imap: remove some intermediate arrays
X-Git-Tag: v1.9.0~5
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2093629bc108e7ce17d932738f692eaa9721c1dd;p=public-inbox.git

imap: remove some intermediate arrays

We can assign arrays directly without `[]' creating an extra
immortal pad allocation.
---

diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 0a65d87c..1f65aa65 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -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;
 }