From 123031737a09edb3297e0fc6ea9e566fc2fecdf5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 14 Oct 2016 09:00:01 +0000 Subject: thread: reinstates stable ordering when ghosts are present This reverts commit 3c9dd6619f825f0515e7e4afa1bd55c99c1a68d3 ("thread: fix sorting without topmost") and reinstates the "topmost" routine for sorting purposes. --- lib/PublicInbox/SearchThread.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/PublicInbox/SearchThread.pm') diff --git a/lib/PublicInbox/SearchThread.pm b/lib/PublicInbox/SearchThread.pm index 24a56d2d..fe70406b 100644 --- a/lib/PublicInbox/SearchThread.pm +++ b/lib/PublicInbox/SearchThread.pm @@ -98,6 +98,16 @@ sub new { }, $_[0]; } +sub topmost { + my ($self) = @_; + my @q = ($self); + while (my $cont = shift @q) { + return $cont if $cont->{smsg}; + push @q, values %{$cont->{children}}; + } + undef; +} + sub add_child { my ($self, $child) = @_; croak "Cowardly refusing to become my own parent: $self" -- cgit v1.2.3-24-ge0c7