]> git.sesse.net Git - plocate/commitdiff
Fix some warnings found by Clang.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Wed, 7 Oct 2020 23:12:48 +0000 (01:12 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Wed, 7 Oct 2020 23:12:48 +0000 (01:12 +0200)
plocate.cpp
turbopfor-encode.h
turbopfor.h

index a9a961e862fd4f79f5f9b2bb89f5729a5e602e84..336483b87efb96c8a863c4b9661715544f7fd2b9 100644 (file)
@@ -162,7 +162,7 @@ Corpus::~Corpus()
 void Corpus::find_trigram(uint32_t trgm, function<void(const Trigram *trgmptr, size_t len)> cb)
 {
        uint32_t bucket = hash_trigram(trgm, hdr.hashtable_size);
-       engine->submit_read(fd, sizeof(Trigram) * (hdr.extra_ht_slots + 2), hdr.hash_table_offset_bytes + sizeof(Trigram) * bucket, [this, trgm, bucket, cb{ move(cb) }](string s) {
+       engine->submit_read(fd, sizeof(Trigram) * (hdr.extra_ht_slots + 2), hdr.hash_table_offset_bytes + sizeof(Trigram) * bucket, [this, trgm, cb{ move(cb) }](string s) {
                const Trigram *trgmptr = reinterpret_cast<const Trigram *>(s.data());
                for (unsigned i = 0; i < hdr.extra_ht_slots + 1; ++i) {
                        if (trgmptr[i].trgm == trgm) {
@@ -382,7 +382,7 @@ void do_search_file(const vector<string> &needles, const char *filename)
                        if (done)
                                break;
                }
-               engine.submit_read(fd, len, trgmptr.offset, [trgmptr, len, &done, &in1, &in2, &out](string s) {
+               engine.submit_read(fd, len, trgmptr.offset, [trgmptr{trgmptr}, len{len}, &done, &in1, &in2, &out](string s) {
                        if (done)
                                return;
                        uint32_t trgm __attribute__((unused)) = trgmptr.trgm;
index 532aa19d07b01faf6643f54153ac019387907d38..693bd301544a9cdcec378b2dd5bc5c2e7547ae17 100644 (file)
 
 #include "turbopfor-common.h"
 
+#include <algorithm>
+
 #include <assert.h>
 #include <limits.h>
 #include <stdint.h>
+#include <string.h>
 
 template<class Docid>
 void write_le(Docid val, void *out)
@@ -27,7 +30,7 @@ void write_le(Docid val, void *out)
        } else if constexpr (sizeof(Docid) == 2) {
                val = htole16(val);
        } else if constexpr (sizeof(Docid) == 1) {
-               val = val;
+               // No change.
        } else {
                assert(false);
        }
index a21727a7375b0ab8df74772ae19110e6aa736c43..6f8ef6f71f27ae626cd235f05def1ec125014465 100644 (file)
@@ -8,6 +8,8 @@
 // delta-plus-1 is implemented, and only 32-bit docids are tested),
 // but aim to be more portable and (ideally) easier-to-understand.
 // In particular, they will compile on x86 without SSE4.1 or AVX support.
+// Unlike the reference code, only GCC and GCC-compatible compilers
+// (e.g. Clang) are supported.
 //
 // The main reference is https://michael.stapelberg.ch/posts/2019-02-05-turbopfor-analysis/,
 // although some implementation details have been worked out by studying the