]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchthread: delete children early while ordering
authorEric Wong <e@80x24.org>
Wed, 22 Jun 2022 08:02:53 +0000 (08:02 +0000)
committerEric Wong <e@80x24.org>
Wed, 22 Jun 2022 16:33:16 +0000 (16:33 +0000)
This allows us to free up some memory sooner rather than later
in case ordersub is expensive.

lib/PublicInbox/SearchThread.pm

index cc8c90ce23d4f51354e5599ecf16810d86afdd6d..00ae9faccc08b7b16aff259fb9cd54165b485eb2 100644 (file)
@@ -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;