]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
search: avoid `git rev-parse' if using C++ xap_helper
authorEric Wong <e@80x24.org>
Wed, 5 Mar 2025 07:18:34 +0000 (07:18 +0000)
committerEric Wong <e@80x24.org>
Fri, 7 Mar 2025 19:23:13 +0000 (19:23 +0000)
The C++ xap_helper can work with the Xapian query parser API to
run run git_date_parse(), so there's no need to do janky string
substitutions as we do for the Perl bindings.

lib/PublicInbox/Search.pm

index 7fbee85940c9c82e02d9caf22c4f7a5392d1b2d9..535d6b83eccadf14c0182460ca1a4a63bebfce66 100644 (file)
@@ -402,6 +402,7 @@ sub date_parse_finalize {
 # if this $argv isn't from a command execution
 sub query_argv_to_string {
        my (undef, $git, $argv) = @_;
+       return "@$argv" if $XHC && $XHC->{impl} eq 'PublicInbox::XapHelperCxx';
        my $to_parse;
        my $tmp = join(' ', map {;
                if (s!\b(d|rt|dt):(\S+)\z!date_parse_prepare(
@@ -420,6 +421,7 @@ sub query_argv_to_string {
 # this is for the WWW "q=" query parameter and "lei q --stdin"
 # it can't do d:"5 days ago", but it will do d:5.days.ago
 sub query_approxidate {
+       return if $XHC && $XHC->{impl} eq 'PublicInbox::XapHelperCxx';
        my (undef, $git) = @_; # $_[2] = $query_string (modified in-place)
        my $DQ = qq<"\x{201c}\x{201d}>; # Xapian can use curly quotes
        $_[2] =~ tr/\x00/ /; # Xapian doesn't do NUL, we use it as a placeholder