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.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_SCC_BODY_TEXT_LINE 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 12F9E1F727 for ; Wed, 22 Jun 2022 08:02:54 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] searchthread: remove + inline single-use cast sub Date: Wed, 22 Jun 2022 08:02:52 +0000 Message-Id: <20220622080253.7760-2-e@80x24.org> In-Reply-To: <20220622080253.7760-1-e@80x24.org> References: <20220622080253.7760-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No point in wasting several kilobytes of memory for a single-use one-line sub. --- lib/PublicInbox/SearchThread.pm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/SearchThread.pm b/lib/PublicInbox/SearchThread.pm index f07dd696..cc8c90ce 100644 --- a/lib/PublicInbox/SearchThread.pm +++ b/lib/PublicInbox/SearchThread.pm @@ -38,13 +38,13 @@ sub thread { # TODO: move this to a more appropriate place, breaks tests # if we do it during psgi_cull delete $_->{num}; - - PublicInbox::SearchThread::Msg::cast($_); + bless $_, 'PublicInbox::SearchThread::Msg'; if (exists $id_table{$_->{mid}}) { $_->{children} = []; push @imposters, $_; # we'll deal with them later undef; } else { + $_->{children} = {}; # will become arrayref later $id_table{$_->{mid}} = $_; defined($_->{references}); } @@ -108,13 +108,6 @@ sub ghost { }, __PACKAGE__; } -# give a existing smsg the methods of this class -sub cast { - my ($smsg) = @_; - $smsg->{children} = {}; - bless $smsg, __PACKAGE__; -} - sub topmost { my ($self) = @_; my @q = ($self);