From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BDA6F1F61C for ; Thu, 4 Aug 2022 08:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1659601024; bh=KpF9KlZBxuDxohHHBjDW3d2RhyQ45C/zBIlPOVynWi8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jf9Xpx+/qiEqEr/GfpTzPq3LVltSTHtZUO+4dRzI3zdMRA0J/RCs9aY6oOoIcwsQn vN+JwrEQjr0W9UZY6fpqE5eQOgY2METIvQVyj+K7/aWe2GUx/2NWPbfsK6e7+hMoWJ kuuq4Po4qI87LeK0Af8GIBKe29JfrftU57SWmXBg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/7] imap: ensure_slices_exist: drop needless map and array Date: Thu, 4 Aug 2022 08:17:01 +0000 Message-Id: <20220804081703.1410595-6-e@80x24.org> In-Reply-To: <20220804081703.1410595-1-e@80x24.org> References: <20220804081703.1410595-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/IMAP.pm | 7 ++----- 1 file 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 ($$;$) {