unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <20220622080253.7760-2-e@80x24.org> (raw)
In-Reply-To: <20220622080253.7760-1-e@80x24.org>

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);

  reply	other threads:[~2022-06-22  8:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  8:02 [PATCH 0/2] searchthread: minor simplifications Eric Wong
2022-06-22  8:02 ` Eric Wong [this message]
2022-06-22  8:02 ` [PATCH 2/2] searchthread: delete children early while ordering Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220622080253.7760-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).