]> Sergey Matveev's repositories - public-inbox.git/commitdiff
extsearchidx: favor binary comparison in common case
authorEric Wong <e@80x24.org>
Sun, 25 Jul 2021 00:43:29 +0000 (00:43 +0000)
committerEric Wong <e@80x24.org>
Sun, 25 Jul 2021 06:14:04 +0000 (06:14 +0000)
We'll use 20-byte SHA-1 comparisons instead of 40-byte
hex representations for a minor reduction in memory
traffic.

lib/PublicInbox/ExtSearchIdx.pm

index 51dbf54f2a1a6dada2d98c1d460b0fe633b2f30f..fb1f511e8bc3a7062d68744bfa37cb75dfa42e57 100644 (file)
@@ -784,16 +784,16 @@ ORDER BY docid,xnum ASC LIMIT 10000
 
                        $fetching = $min = $docid;
                        my $smsg = $ibx->over->get_art($xnum);
-                       my $oidhex = unpack('H*', $oidbin);
                        my $err;
                        if (!$smsg) {
                                $err = 'stale';
-                       } elsif ($smsg->{blob} ne $oidhex) {
+                       } elsif (pack('H*', $smsg->{blob}) ne $oidbin) {
                                $err = "mismatch (!= $smsg->{blob})";
                        } else {
                                next; # likely, all good
                        }
                        # current_info already has eidx_key
+                       my $oidhex = unpack('H*', $oidbin);
                        warn "$xnum:$oidhex (#$docid): $err\n";
                        my $del = $self->{oidx}->dbh->prepare_cached(<<'');
 DELETE FROM xref3 WHERE ibx_id = ? AND xnum = ? AND oidbin = ?