]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
searchidx: use vstring to improve readability
authorEric Wong <e@80x24.org>
Fri, 7 Apr 2023 12:40:52 +0000 (12:40 +0000)
committerEric Wong <e@80x24.org>
Fri, 7 Apr 2023 22:17:22 +0000 (22:17 +0000)
Perl has native `vstring' encoding for vector (or version)
strings, make use of it instead of relying on difficult-to-read
hex versions and integer shifts.

lib/PublicInbox/SearchIdx.pm

index 511dd4d6b66e8ff44935ad8ad99b2a7187d0f639..496cea05f4949a52cd2b0210cd268a2f028d9b24 100644 (file)
@@ -114,15 +114,15 @@ sub load_xapian_writable () {
        *sortable_serialise = $xap.'::sortable_serialise';
        $DB_CREATE_OR_OPEN = eval($xap.'::DB_CREATE_OR_OPEN()');
        $DB_OPEN = eval($xap.'::DB_OPEN()');
-       my $ver = (eval($xap.'::major_version()') << 16) |
-               (eval($xap.'::minor_version()') << 8) |
-               eval($xap.'::revision()');
-       if ($ver >= 0x10400) {
+       my $ver = eval 'v'.join('.', eval($xap.'::major_version()'),
+                               eval($xap.'::minor_version()'),
+                               eval($xap.'::revision()'));
+       if ($ver ge 1.4) { # new flags in Xapian 1.4
                $DB_NO_SYNC = 0x4;
                $DB_DANGEROUS = 0x10;
        }
        # Xapian v1.2.21..v1.2.24 were missing close-on-exec on OFD locks
-       $X->{CLOEXEC_UNSET} = 1 if $ver >= 0x010215 && $ver <= 0x010218;
+       $X->{CLOEXEC_UNSET} = 1 if $ver ge v1.2.21 && $ver le v1.2.24;
        1;
 }