]> git.sesse.net Git - plocate/blobdiff - plocate.cpp
Start reimplementing the TurboPFor decoding functions.
[plocate] / plocate.cpp
index dc64b384b330052e6fd23b53498a839b7f7b28e4..9b1f234c1b8e3653ba314f9208e172d129f09692 100644 (file)
@@ -10,6 +10,7 @@
 #include <fcntl.h>
 #include <functional>
 #include <getopt.h>
+#include <limits.h>
 #include <memory>
 #include <stdio.h>
 #include <string.h>
@@ -25,6 +26,8 @@ using namespace std::chrono;
 #define dprintf(...)
 //#define dprintf(...) fprintf(stderr, __VA_ARGS__);
 
+#include "turbopfor.h"
+
 const char *dbpath = "/var/lib/mlocate/plocate.db";
 bool print_nul = false;
 
@@ -388,7 +391,7 @@ void do_search_file(const vector<string> &needles, const char *filename)
                        unsigned char *pldata = reinterpret_cast<unsigned char *>(s.data());
                        if (in1.empty()) {
                                in1.resize(num + 128);
-                               p4nd1dec32(pldata, num, &in1[0]);
+                               decode_pfor_delta1<128>(pldata, num, &in1[0]);
                                in1.resize(num);
                                dprintf("trigram '%c%c%c' (%zu bytes) decoded to %zu entries\n", trgm & 0xff,
                                        (trgm >> 8) & 0xff, (trgm >> 16) & 0xff, len, num);
@@ -396,7 +399,7 @@ void do_search_file(const vector<string> &needles, const char *filename)
                                if (in2.size() < num + 128) {
                                        in2.resize(num + 128);
                                }
-                               p4nd1dec32(pldata, num, &in2[0]);
+                               decode_pfor_delta1<128>(pldata, num, &in2[0]);
 
                                out.clear();
                                set_intersection(in1.begin(), in1.end(), in2.begin(), in2.begin() + num,