diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-08-29 19:19:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 19:19:37 +0200 |
commit | 0f17d15350a11e991f4d477c9346d2788e22294f (patch) | |
tree | 41dcaa2ad44870eb67460983434e0fb85e78c02b /searchlib/src | |
parent | 382bad5ed1a824b679b9f755d1a0e97f1a7f0977 (diff) | |
parent | 5190dcda5079bc746cd05d6296d84435a66faa4a (diff) |
Merge pull request #23838 from vespa-engine/balder/gc-unused-code
GC some old unused code with ancient 'goto'.....
Diffstat (limited to 'searchlib/src')
6 files changed, 7 insertions, 77 deletions
diff --git a/searchlib/src/tests/util/rawbuf_test.cpp b/searchlib/src/tests/util/rawbuf_test.cpp index fd77b5b4ddb..ca7221d0240 100644 --- a/searchlib/src/tests/util/rawbuf_test.cpp +++ b/searchlib/src/tests/util/rawbuf_test.cpp @@ -116,23 +116,6 @@ TEST("require that prealloc makes enough room") { EXPECT_LESS_EQUAL(100u, buf.GetFreeLen()); } -TEST("require that rawbuf can read from file") { - FastOS_File file("mytemporaryfile"); - ASSERT_TRUE(file.OpenReadWrite()); - ASSERT_EQUAL(6, file.Write2("barbaz", 6)); - file.SetPosition(0); - - RawBuf buf(10); - buf += "foo"; - buf.readFile(file, 3); - EXPECT_EQUAL("foobar", getString(buf)); - buf.readFile(file, 100); - EXPECT_EQUAL("foobarbaz", getString(buf)); - - ASSERT_TRUE(file.Close()); - file.Delete(); -} - TEST("require that compact discards drained data") { RawBuf buf(10); buf += "foobar"; diff --git a/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h b/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h index b32c8fc1663..58aba882e8d 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h +++ b/searchlib/src/vespa/searchlib/attribute/attributememorysavetarget.h @@ -5,7 +5,6 @@ #include "attributememoryfilewriter.h" #include "iattributesavetarget.h" #include <vespa/searchlib/common/tunefileinfo.h> -#include <vespa/searchlib/util/rawbuf.h> #include <vespa/vespalib/stllike/hash_fun.h> #include <memory> #include <unordered_map> @@ -37,7 +36,7 @@ private: public: AttributeMemorySaveTarget(); - ~AttributeMemorySaveTarget(); + ~AttributeMemorySaveTarget() override; /** * Write the underlying buffer(s) to file(s). diff --git a/searchlib/src/vespa/searchlib/parsequery/parse.h b/searchlib/src/vespa/searchlib/parsequery/parse.h index c3b5fcc81fa..1285125d34b 100644 --- a/searchlib/src/vespa/searchlib/parsequery/parse.h +++ b/searchlib/src/vespa/searchlib/parsequery/parse.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/searchlib/query/weight.h> -#include <vespa/searchlib/util/rawbuf.h> #include <vespa/vespalib/stllike/string.h> namespace search { diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp index 5ed33ec18a1..9bb62e76c49 100644 --- a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp +++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp @@ -8,6 +8,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/searchlib/parsequery/parse.h> +#include <vespa/searchlib/util/rawbuf.h> using vespalib::string; using std::vector; diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.cpp b/searchlib/src/vespa/searchlib/util/rawbuf.cpp index d3cc9996c34..d64d85f2f1d 100644 --- a/searchlib/src/vespa/searchlib/util/rawbuf.cpp +++ b/searchlib/src/vespa/searchlib/util/rawbuf.cpp @@ -2,14 +2,12 @@ #include "rawbuf.h" #include <vespa/vespalib/util/compress.h> -#include <vespa/fastos/file.h> #include <cassert> #include <cstring> +#include <cstdio> namespace search { -static inline size_t smin(size_t a, size_t b) { return (a < b) ? a : b; } - RawBuf::RawBuf(size_t size) : _bufStart(nullptr), _bufEnd(nullptr), @@ -25,21 +23,6 @@ RawBuf::RawBuf(size_t size) _bufDrainPos = _bufFillPos = _bufStart; } - -RawBuf::RawBuf(char *start, size_t size) - : _bufStart(nullptr), - _bufEnd(nullptr), - _bufFillPos(nullptr), - _bufDrainPos(nullptr), - _initialBufStart(start), - _initialSize(size) -{ - _bufStart = start; - _bufEnd = _bufStart + size; - _bufDrainPos = _bufFillPos = _bufStart; -} - - RawBuf::~RawBuf() { if (_bufStart != _initialBufStart) @@ -109,17 +92,6 @@ RawBuf::appendCompressedNumber(int64_t n) _bufFillPos += vespalib::compress::Integer::compress(n, _bufFillPos); } - -/** - * Has the entire contents of the buffer been used up, i.e. freed? - */ -bool -RawBuf::IsEmpty() -{ - return _bufFillPos == _bufDrainPos; -} - - /** * Free 'len' bytes from the start of the contents. (These * have presumably been written or read.) @@ -345,19 +317,6 @@ RawBuf::addSignedHitRank(SignedHitRank num) append(buf1, strlen(buf1)); } -/** - * Read from the indicated file into the buffer, no more that the - * given number of bytes and no more than will fit in the buffer. - */ -size_t -RawBuf::readFile(FastOS_FileInterface &file, size_t maxlen) -{ - size_t got = file.Read(_bufFillPos, smin((_bufEnd - _bufFillPos), maxlen)); - if (got > 0) - _bufFillPos += got; - return got; -} - void RawBuf::ensureSizeInternal(size_t size) { expandBuf(size); diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.h b/searchlib/src/vespa/searchlib/util/rawbuf.h index e69c13e13b3..258e3da88ed 100644 --- a/searchlib/src/vespa/searchlib/util/rawbuf.h +++ b/searchlib/src/vespa/searchlib/util/rawbuf.h @@ -19,9 +19,6 @@ namespace search { class RawBuf { private: - RawBuf(const RawBuf &); - RawBuf& operator=(const RawBuf &); - char* _bufStart; // ref. to start of buffer (don't move this!) char* _bufEnd; // ref. to byte after last in buffer (don't mo) char* _bufFillPos; // ref. to byte where next should be put in @@ -31,9 +28,9 @@ private: void ensureSizeInternal(size_t size); public: - - RawBuf(char *start, size_t size);// Initially use provided buffer - RawBuf(size_t size); // malloc-s given size, assigns to _bufStart + RawBuf(const RawBuf &) = delete; + RawBuf& operator=(const RawBuf &) = delete; + explicit RawBuf(size_t size); // malloc-s given size, assigns to _bufStart ~RawBuf(); // Frees _bufStart, i.e. the char[]. void operator+=(const char *src); @@ -48,10 +45,8 @@ public: void append(const void *data, size_t len); void append(uint8_t byte); - void appendLong(uint64_t n); void appendCompressedPositiveNumber(uint64_t n); void appendCompressedNumber(int64_t n); - bool IsEmpty(); // Return whether all written. void expandBuf(size_t needlen); size_t GetFreeLen() const { return _bufEnd - _bufFillPos; } size_t GetDrainLen() const { return _bufDrainPos - _bufStart; } @@ -59,7 +54,6 @@ public: const char *GetFillPos() const { return _bufFillPos; } char * GetWritableFillPos() const { return _bufFillPos; } char * GetWritableFillPos(size_t len) { preAlloc(len); return _bufFillPos; } - char * GetWritableDrainPos(size_t offset) { return _bufDrainPos + offset; } void truncate(size_t offset) { _bufFillPos = _bufDrainPos + offset; } void preAlloc(size_t len); // Ensure room for 'len' more bytes. size_t readFile(FastOS_FileInterface &file, size_t maxlen); @@ -83,16 +77,11 @@ public: static uint16_t InetTo16(const unsigned char *src) { return (static_cast<uint16_t>(*src) << 8) + *(src + 1); }; - static uint16_t InetTo16(const char* src) { - return InetTo16(reinterpret_cast<const unsigned char *>(src)); - }; + static uint32_t InetTo32(const unsigned char* src) { return (((((static_cast<uint32_t>(*src) << 8) + *(src + 1)) << 8) + *(src + 2)) << 8) + *(src + 3); }; - static uint32_t InetTo32(const char* src) { - return InetTo32(reinterpret_cast<const unsigned char *>(src)); - }; /** * Convert unsigned int.s 'src', to interNet highendian order, at 'dst' |