From d0147582e289fdd4cdd84e91d8b0f8ae9c230124 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 17 Apr 2020 09:28:49 +0000 Subject: searchthread: reduce indirection by removing container We can rid ourselves of a layer of indirection by subclassing PublicInbox::Smsg instead of using a container object to hold each $smsg. Furthermore, the `{id}' vs. `{mid}' field name confusion is eliminated. This reduces the size of the $rootset passed to walk_thread by around 15%, that is over 50K memory when rendering a /$INBOX/ landing page. --- t/thread-cycle.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 't/thread-cycle.t') diff --git a/t/thread-cycle.t b/t/thread-cycle.t index e9ea0a27..d6545c6d 100644 --- a/t/thread-cycle.t +++ b/t/thread-cycle.t @@ -19,6 +19,7 @@ sub make_objs { my $msg = $_; $msg->{ds} ||= ++$n; $msg->{references} =~ s/\s+/ /sg if $msg->{references}; + $msg->{blob} = '0'x40; # any dummy value will do, here my $simple = Email::Simple->create(header => [ 'Message-ID' => "<$msg->{mid}>", 'References' => $msg->{references}, @@ -100,13 +101,13 @@ done_testing(); sub thread_to_s { my ($msgs) = @_; my $rootset = PublicInbox::SearchThread::thread($msgs, sub { - [ sort { $a->{id} cmp $b->{id} } @{$_[0]} ] }); + [ sort { $a->{mid} cmp $b->{mid} } @{$_[0]} ] }); my $st = ''; my @q = map { (0, $_) } @$rootset; while (@q) { my $level = shift @q; my $node = shift @q or next; - $st .= (" "x$level). "$node->{id}\n"; + $st .= (" "x$level). "$node->{mid}\n"; my $cl = $level + 1; unshift @q, map { ($cl, $_) } @{$node->{children}}; } -- cgit v1.2.3-24-ge0c7