unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/4] lei_search: favor binary OID comparisons
Date: Sun, 25 Jul 2021 00:43:30 +0000	[thread overview]
Message-ID: <20210725004332.23896-3-e@80x24.org> (raw)
In-Reply-To: <20210725004332.23896-1-e@80x24.org>

Reduce memory traffic and code, too.
---
 lib/PublicInbox/LeiExportKw.pm | 7 +++----
 lib/PublicInbox/LeiSearch.pm   | 6 +++---
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm
index 671a84df..42a5ff22 100644
--- a/lib/PublicInbox/LeiExportKw.pm
+++ b/lib/PublicInbox/LeiExportKw.pm
@@ -10,8 +10,7 @@ use Errno qw(EEXIST ENOENT);
 
 sub export_kw_md { # LeiMailSync->each_src callback
 	my ($oidbin, $id, $self, $mdir) = @_;
-	my $oidhex = unpack('H*', $oidbin);
-	my $sto_kw = $self->{lse}->oid_keywords($oidhex) or return;
+	my $sto_kw = $self->{lse}->oidbin_keywords($oidbin) or return;
 	my $bn = $$id;
 	my ($md_kw, $unknown, @try);
 	if ($bn =~ s/:2,([a-zA-Z]*)\z//) {
@@ -57,13 +56,13 @@ sub export_kw_md { # LeiMailSync->each_src callback
 	# both tries failed
 	my $e = $!;
 	my $orig = '['.join('|', @fail).']';
+	my $oidhex = unpack('H*', $oidbin);
 	$lei->child_error(1, "link($orig, $dst) ($oidhex): $e");
 }
 
 sub export_kw_imap { # LeiMailSync->each_src callback
 	my ($oidbin, $id, $self, $mic) = @_;
-	my $oidhex = unpack('H*', $oidbin);
-	my $sto_kw = $self->{lse}->oid_keywords($oidhex) or return;
+	my $sto_kw = $self->{lse}->oidbin_keywords($oidbin) or return;
 	$self->{imap_mod_kw}->($self->{nwr}, $mic, $id, [ keys %$sto_kw ]);
 }
 
diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm
index 37bfc65e..79b2fd7d 100644
--- a/lib/PublicInbox/LeiSearch.pm
+++ b/lib/PublicInbox/LeiSearch.pm
@@ -42,9 +42,9 @@ sub _oid_kw { # retry_reopen callback
 }
 
 # returns undef if blob is unknown
-sub oid_keywords {
-	my ($self, $oidhex) = @_;
-	my @num = $self->over->blob_exists($oidhex) or return;
+sub oidbin_keywords {
+	my ($self, $oidbin) = @_;
+	my @num = $self->over->oidbin_exists($oidbin) or return;
 	$self->retry_reopen(\&_oid_kw, \@num);
 }
 

  parent reply	other threads:[~2021-07-25  0:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-25  0:43 [PATCH 0/4] favor shorter binary OID comparisons Eric Wong
2021-07-25  0:43 ` [PATCH 1/4] extsearchidx: favor binary comparison in common case Eric Wong
2021-07-25  0:43 ` Eric Wong [this message]
2021-07-25  0:43 ` [PATCH 3/4] lei_inspect: fix typo Eric Wong
2021-07-25  0:43 ` [PATCH 4/4] lei_mail_sync: locations_for API uses oidbin for comparisons Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210725004332.23896-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).