about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-08-04 08:17:01 +0000
committerEric Wong <e@80x24.org>2022-08-04 20:09:35 +0000
commit956fa442de1699e078cc7babb7a34af83d143307 (patch)
treefb039457a4d215bdea30deb4c6f49d84df3e6beb
parentfca813000ce319e9a320f0fdc9ee7272810f8833 (diff)
downloadpublic-inbox-956fa442de1699e078cc7babb7a34af83d143307.tar.gz
We can reduce ops and temporary objects here by folding the
stringification into the `for' loop and push directly into the
{mailboxlist} array; relying on autovivification to turn it into
a noop for the initial population.
-rw-r--r--lib/PublicInbox/IMAP.pm7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 9955984b..bed633e5 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -354,17 +354,14 @@ sub ensure_slices_exist ($$) {
         my ($imapd, $ibx) = @_;
         my $mb_top = $ibx->{newsgroup} // return;
         my $mailboxes = $imapd->{mailboxes};
-        my @created;
+        my $list = $imapd->{mailboxlist}; # may be undef, just autoviv + noop
         for (my $i = int($ibx->art_max/UID_SLICE); $i >= 0; --$i) {
                 my $sub_mailbox = "$mb_top.$i";
                 last if exists $mailboxes->{$sub_mailbox};
                 $mailboxes->{$sub_mailbox} = $ibx;
                 $sub_mailbox =~ s/\Ainbox\./INBOX./i; # more familiar to users
-                push @created, $sub_mailbox;
+                push @$list, qq[* LIST (\\HasNoChildren) "." $sub_mailbox\r\n]
         }
-        return unless @created;
-        my $l = $imapd->{mailboxlist} or return;
-        push @$l, map { qq[* LIST (\\HasNoChildren) "." $_\r\n] } @created;
 }
 
 sub inbox_lookup ($$;$) {