From c36cd135f2e514a6dafe04ca500f814a1f0593b0 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 30 Sep 2020 20:03:54 +0200 Subject: [PATCH] Fix a bug where posting lists intersecting to nothing would not early-abort properly. --- plocate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plocate.cpp b/plocate.cpp index 84fcd7a..ea7a4e8 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -339,6 +339,7 @@ void do_search_file(const string &needle, const char *filename) break; } engine.submit_read(fd, len, trgmptr.offset, [trgmptr, len, &done, &in1, &in2, &out](string s) { + if (done) return; uint32_t trgm __attribute__((unused)) = trgmptr.trgm; size_t num = trgmptr.num_docids; unsigned char *pldata = reinterpret_cast(s.data()); @@ -369,6 +370,9 @@ void do_search_file(const string &needle, const char *filename) }); } engine.finish(); + if (done) { + return; + } dprintf("Intersection done after %.1f ms. Doing final verification and printing:\n", 1e3 * duration(steady_clock::now() - start).count()); -- 2.39.2