unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/2] searchthread: minor simplifications
@ 2022-06-22  8:02 Eric Wong
  2022-06-22  8:02 ` [PATCH 1/2] searchthread: remove + inline single-use cast sub Eric Wong
  2022-06-22  8:02 ` [PATCH 2/2] searchthread: delete children early while ordering Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2022-06-22  8:02 UTC (permalink / raw)
  To: meta

A few patches I've had floating around since last Nov before
I completely forgot about some things :x

Eric Wong (2):
  searchthread: remove + inline single-use cast sub
  searchthread: delete children early while ordering

 lib/PublicInbox/SearchThread.pm | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] searchthread: remove + inline single-use cast sub
  2022-06-22  8:02 [PATCH 0/2] searchthread: minor simplifications Eric Wong
@ 2022-06-22  8:02 ` Eric Wong
  2022-06-22  8:02 ` [PATCH 2/2] searchthread: delete children early while ordering Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-06-22  8:02 UTC (permalink / raw)
  To: meta

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] searchthread: delete children early while ordering
  2022-06-22  8:02 [PATCH 0/2] searchthread: minor simplifications Eric Wong
  2022-06-22  8:02 ` [PATCH 1/2] searchthread: remove + inline single-use cast sub Eric Wong
@ 2022-06-22  8:02 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-06-22  8:02 UTC (permalink / raw)
  To: meta

This allows us to free up some memory sooner rather than later
in case ordersub is expensive.
---
 lib/PublicInbox/SearchThread.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/SearchThread.pm b/lib/PublicInbox/SearchThread.pm
index cc8c90ce..00ae9fac 100644
--- a/lib/PublicInbox/SearchThread.pm
+++ b/lib/PublicInbox/SearchThread.pm
@@ -167,7 +167,7 @@ sub order_children {
 	while (defined($cur = shift @q)) {
 		# the {children} hashref here...
 		my @c = grep { !$seen{$_}++ && visible($_, $ibx) }
-			values %{$cur->{children}};
+			values %{delete $cur->{children}};
 		$ordersub->(\@c) if scalar(@c) > 1;
 		$cur->{children} = \@c; # ...becomes an arrayref
 		push @q, @c;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-22  8:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  8:02 [PATCH 0/2] searchthread: minor simplifications Eric Wong
2022-06-22  8:02 ` [PATCH 1/2] searchthread: remove + inline single-use cast sub Eric Wong
2022-06-22  8:02 ` [PATCH 2/2] searchthread: delete children early while ordering Eric Wong

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