From 2c0e3e3c68772d06b2a842c1c5403b382763deec Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Sat, 25 Apr 2020 23:42:21 +0200 Subject: Move BufferWriter back to searchlib. --- .../src/vespa/vespalib/datastore/unique_store.hpp | 1 - vespalib/src/vespa/vespalib/util/CMakeLists.txt | 1 - vespalib/src/vespa/vespalib/util/bufferwriter.cpp | 36 -------------- vespalib/src/vespa/vespalib/util/bufferwriter.h | 56 ---------------------- 4 files changed, 94 deletions(-) delete mode 100644 vespalib/src/vespa/vespalib/util/bufferwriter.cpp delete mode 100644 vespalib/src/vespa/vespalib/util/bufferwriter.h (limited to 'vespalib') diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp index 33830bbe4ab..956d4c16d40 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -10,7 +10,6 @@ #include "unique_store_builder.hpp" #include "unique_store_dictionary.hpp" #include "unique_store_enumerator.hpp" -#include #include #include diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index e3397b54740..4029c4881c4 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -12,7 +12,6 @@ vespa_add_library(vespalib_vespalib_util OBJECT benchmark_timer.cpp blockingthreadstackexecutor.cpp box.cpp - bufferwriter.cpp classname.cpp closuretask.cpp compress.cpp diff --git a/vespalib/src/vespa/vespalib/util/bufferwriter.cpp b/vespalib/src/vespa/vespalib/util/bufferwriter.cpp deleted file mode 100644 index 6e57d6f58d4..00000000000 --- a/vespalib/src/vespa/vespalib/util/bufferwriter.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "bufferwriter.h" - -namespace search { - -BufferWriter::BufferWriter() - : _cur(nullptr), - _end(nullptr), - _start(nullptr) -{ -} - -BufferWriter::~BufferWriter() = default; - -void -BufferWriter::writeSlow(const void *src, size_t len) -{ - size_t residue = len; - const char *csrc = static_cast(src); - for (;;) { - size_t maxLen = freeLen(); - if (residue <= maxLen) { - writeFast(csrc, residue); - break; - } - if (maxLen != 0) { - writeFast(csrc, maxLen); - csrc += maxLen; - residue -= maxLen; - } - flush(); - } -} - -} // namespace search diff --git a/vespalib/src/vespa/vespalib/util/bufferwriter.h b/vespalib/src/vespa/vespalib/util/bufferwriter.h deleted file mode 100644 index 3da6e3f8030..00000000000 --- a/vespalib/src/vespa/vespalib/util/bufferwriter.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include - -namespace search { - -/** - * Abstract class to write to a buffer with an abstract backing store - * and abstract backing buffer. Each time backing buffer is full, - * flush() is called to resize it or drain it to the backing store. - */ -class BufferWriter -{ - char *_cur; - char *_end; - char *_start; -protected: - void rewind() { _cur = _start; } - - void setup(void *start, size_t len) { - _start = static_cast(start); - _end = _start + len; - rewind(); - } - - size_t freeLen() const { return _end - _cur; } - size_t usedLen() const { return _cur - _start; } - - void writeFast(const void *src, size_t len) - { - __builtin_memcpy(_cur, src, len); - _cur += len; - } - - void writeSlow(const void *src, size_t len); - -public: - BufferWriter(); - - virtual ~BufferWriter(); - - virtual void flush() = 0; - - void write(const void *src, size_t len) - { - if (__builtin_expect(len <= freeLen(), true)) { - writeFast(src, len); - return; - } - writeSlow(src, len); - } -}; - -} // namespace search -- cgit v1.2.3