about summary refs log tree commit homepage
path: root/lib/PublicInbox/Mbox.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-02 00:04:55 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-02 00:05:42 +0000
commit87dca6d8d5988c5eb54019cca342450b0b7dd6b7 (patch)
treea415a88759b88014d30544addbb69c5949ed76f0 /lib/PublicInbox/Mbox.pm
parent3cc5ff405d9054fbf47ac44774fca4f9a72ff65a (diff)
downloadpublic-inbox-87dca6d8d5988c5eb54019cca342450b0b7dd6b7.tar.gz
In many cases, we do not care about the total number of
messages.  It's a rather expensive operation in SQLite
(Xapian only provides an estimate).

For LKML, this brings top-level /$INBOX/ loading time from
~375ms to around 60ms on my system.  Days ago, this operation
was taking 800-900ms(!) for me before introducing the SQLite
overview DB.
Diffstat (limited to 'lib/PublicInbox/Mbox.pm')
-rw-r--r--lib/PublicInbox/Mbox.pm12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 1b68f027..05de6be1 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -217,12 +217,12 @@ sub set_filename ($$) {
 sub getline {
         my ($self) = @_;
         my $ctx = $self->{ctx} or return;
-        my $res;
         my $ibx = $ctx->{-inbox};
         my $gz = $self->{gz};
+        my $msgs = $self->{msgs};
         do {
                 # work on existing result set
-                while (defined(my $smsg = shift @{$self->{msgs}})) {
+                while (defined(my $smsg = shift @$msgs)) {
                         my $msg = eval { $ibx->msg_by_smsg($smsg) } or next;
                         $msg = Email::Simple->new($msg);
                         $gz->write(PublicInbox::Mbox::msg_str($ctx, $msg,
@@ -247,11 +247,9 @@ sub getline {
                 }
 
                 # refill result set
-                $res = $self->{cb}->($self->{opts});
-                $self->{msgs} = $res->{msgs};
-                $res = scalar @{$self->{msgs}};
-                $self->{opts}->{offset} += $res;
-        } while ($res);
+                $msgs = $self->{msgs} = $self->{cb}->($self->{opts});
+                $self->{opts}->{offset} += scalar @$msgs;
+        } while (@$msgs);
         $gz->close;
         delete $self->{ctx};
         ${delete $self->{buf}};