about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-11-23 07:06:02 +0000
committerEric Wong <e@80x24.org>2020-11-24 05:03:55 +0000
commit4047a96cc1697dae5e9724c1e3610e5c992d92c8 (patch)
tree2972df919e70dcbc64f01da6deb26326794a631d
parentbe688d5b00bb77c6601b3ab680403ecd71ac4871 (diff)
downloadpublic-inbox-4047a96cc1697dae5e9724c1e3610e5c992d92c8.tar.gz
Every callback uses `$self', and creating short-lived
array references is not necessary when it's just as
easy to copy the array in Perl (unlike C).
-rw-r--r--lib/PublicInbox/MiscSearch.pm8
-rw-r--r--lib/PublicInbox/Search.pm10
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/PublicInbox/MiscSearch.pm b/lib/PublicInbox/MiscSearch.pm
index 5a44d751..48ef6914 100644
--- a/lib/PublicInbox/MiscSearch.pm
+++ b/lib/PublicInbox/MiscSearch.pm
@@ -50,7 +50,7 @@ sub mi_qp_new ($) {
 }
 
 sub misc_enquire_once { # retry_reopen callback
-        my ($self, $qr, $opt) = @{$_[0]};
+        my ($self, $qr, $opt) = @_;
         my $eq = $PublicInbox::Search::X{Enquire}->new($self->{xdb});
         $eq->set_query($qr);
         my $desc = !$opt->{asc};
@@ -73,11 +73,11 @@ sub mset {
         $qs = 'type:inbox' if $qs eq '';
         my $qr = $qp->parse_query($qs, $PublicInbox::Search::QP_FLAGS);
         $opt->{relevance} = 1 unless exists $opt->{relevance};
-        retry_reopen($self, \&misc_enquire_once, [ $self, $qr, $opt ]);
+        retry_reopen($self, \&misc_enquire_once, $qr, $opt);
 }
 
 sub ibx_data_once {
-        my ($self, $ibx) = @{$_[0]};
+        my ($self, $ibx) = @_;
         my $xdb = $self->{xdb};
         my $eidx_key = $ibx->eidx_key; # may be {inboxdir}, so private
         my $head = $xdb->postlist_begin('Q'.$eidx_key);
@@ -92,7 +92,7 @@ sub ibx_data_once {
 
 sub inbox_data {
         my ($self, $ibx) = @_;
-        retry_reopen($self, \&ibx_data_once, [ $self, $ibx ]);
+        retry_reopen($self, \&ibx_data_once, $ibx);
 }
 
 1;
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 05d5a133..574bc145 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -291,15 +291,15 @@ sub mset {
 }
 
 sub retry_reopen {
-        my ($self, $cb, $arg) = @_;
+        my ($self, $cb, @arg) = @_;
         for my $i (1..10) {
                 if (wantarray) {
                         my @ret;
-                        eval { @ret = $cb->($arg) };
+                        eval { @ret = $cb->($self, @arg) };
                         return @ret unless $@;
                 } else {
                         my $ret;
-                        eval { $ret = $cb->($arg) };
+                        eval { $ret = $cb->($self, @arg) };
                         return $ret unless $@;
                 }
                 # Exception: The revision being read has been discarded -
@@ -319,7 +319,7 @@ sub retry_reopen {
 
 sub _do_enquire {
         my ($self, $query, $opts) = @_;
-        retry_reopen($self, \&_enquire_once, [ $self, $query, $opts ]);
+        retry_reopen($self, \&_enquire_once, $query, $opts);
 }
 
 # returns true if all docs have the THREADID value
@@ -329,7 +329,7 @@ sub has_threadid ($) {
 }
 
 sub _enquire_once { # retry_reopen callback
-        my ($self, $query, $opts) = @{$_[0]};
+        my ($self, $query, $opts) = @_;
         my $xdb = xdb($self);
         my $enquire = $X{Enquire}->new($xdb);
         $enquire->set_query($query);