* [PATCH 2/4] lei_search: favor binary OID comparisons
2021-07-25 0:43 7% [PATCH 0/4] favor shorter binary OID comparisons Eric Wong
@ 2021-07-25 0:43 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-07-25 0:43 UTC (permalink / raw)
To: meta
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);
}
^ permalink raw reply related [relevance 6%]
* [PATCH 0/4] favor shorter binary OID comparisons
@ 2021-07-25 0:43 7% Eric Wong
2021-07-25 0:43 6% ` [PATCH 2/4] lei_search: favor " Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-07-25 0:43 UTC (permalink / raw)
To: meta
We were doing unneccessary 40-byte hex comparisons for SHA-1s
in our code when 20-byte comparisons would've been sufficient.
3/4 is a typo fix which didn't hit any warnings before,
either...
Eric Wong (4):
extsearchidx: favor binary comparison in common case
lei_search: favor binary OID comparisons
lei_inspect: fix typo
lei_mail_sync: locations_for API uses oidbin for comparisons
lib/PublicInbox/ExtSearchIdx.pm | 4 ++--
lib/PublicInbox/LeiExportKw.pm | 7 +++----
lib/PublicInbox/LeiInspect.pm | 7 ++++---
lib/PublicInbox/LeiMailSync.pm | 7 ++++---
lib/PublicInbox/LeiSearch.pm | 6 +++---
t/lei_mail_sync.t | 4 ++--
6 files changed, 18 insertions(+), 17 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-07-25 0:43 7% [PATCH 0/4] favor shorter binary OID comparisons Eric Wong
2021-07-25 0:43 6% ` [PATCH 2/4] lei_search: favor " Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).