about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-28 21:43:17 +0000
committerEric Wong <e@80x24.org>2019-12-28 21:43:17 +0000
commit65e3cc8f6cc73e45db827cbeee4ccecbf1502496 (patch)
treec7575754de71f56b92b9ac808cc3d675f374fef2 /lib/PublicInbox/Search.pm
parentac1ac3b4e2858bcee5a644aac8b6320422ea7383 (diff)
parentf2364c5765f0692d2f1e82b61804359a38f3fdfc (diff)
downloadpublic-inbox-65e3cc8f6cc73e45db827cbeee4ccecbf1502496.tar.gz
* no-closure: (30 commits)
  search: retry_reopen passes user arg to callback
  solvergit: allow passing arg to user-supplied callback
  viewvcs: avoid anonymous sub for HTML response
  wwwattach: avoid anonymous sub for msg_iter
  view: msg_iter calls add_body_text directly
  searchview: remove anonymous sub when sorting threads by relevance
  view: thread_html: pass named sub to WwwStream
  searchview: pass named subs to Www*Stream
  wwwtext: avoid anonymous sub in response
  contentid: no anonymous sub
  view: msg_html: stop using an anonymous sub
  view: avoid anon sub in stream_thread
  config: each_inbox: pass user arg to callback
  feed: avoid anonymous subs
  mboxgz: pass $ctx to callback to avoid anon subs
  www: lazy load Plack::Util
  githttpbackend: split out wwwstatic
  qspawn: psgi_return: allow non-anon parse_hdr callback
  qspawn: drop "qspawn.filter" support, for now
  qspawn: psgi_qx: eliminate anonymous subs
  ...
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 65c6ee83..eb1a1446 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -231,15 +231,15 @@ sub query {
 }
 
 sub retry_reopen {
-        my ($self, $cb) = @_;
+        my ($self, $cb, $arg) = @_;
         for my $i (1..10) {
                 if (wantarray) {
                         my @ret;
-                        eval { @ret = $cb->() };
+                        eval { @ret = $cb->($arg) };
                         return @ret unless $@;
                 } else {
                         my $ret;
-                        eval { $ret = $cb->() };
+                        eval { $ret = $cb->($arg) };
                         return $ret unless $@;
                 }
                 # Exception: The revision being read has been discarded -
@@ -259,11 +259,11 @@ sub retry_reopen {
 
 sub _do_enquire {
         my ($self, $query, $opts) = @_;
-        retry_reopen($self, sub { _enquire_once($self, $query, $opts) });
+        retry_reopen($self, \&_enquire_once, [ $self, $query, $opts ]);
 }
 
-sub _enquire_once {
-        my ($self, $query, $opts) = @_;
+sub _enquire_once { # retry_reopen callback
+        my ($self, $query, $opts) = @{$_[0]};
         my $xdb = xdb($self);
         my $enquire = $X{Enquire}->new($xdb);
         $enquire->set_query($query);
@@ -281,9 +281,7 @@ sub _enquire_once {
         my $limit = $opts->{limit} || 50;
         my $mset = $enquire->get_mset($offset, $limit);
         return $mset if $opts->{mset};
-        my @msgs = map {
-                PublicInbox::SearchMsg->load_doc($_->get_document);
-        } $mset->items;
+        my @msgs = map { PublicInbox::SearchMsg::from_mitem($_) } $mset->items;
         return \@msgs unless wantarray;
 
         ($mset->get_matches_estimated, \@msgs)