refactor: VectorWriter without nVersion

The field is unused, so remove it.

This is also required for future commits.
This commit is contained in:
MarcoFalke
2023-11-16 12:59:43 +01:00
parent 98b0acda0f
commit fa0ed07941
9 changed files with 33 additions and 43 deletions

View File

@@ -51,9 +51,9 @@ FUZZ_TARGET(golomb_rice)
for (int i = 0; i < n; ++i) {
elements.insert(ConsumeRandomLengthByteVector(fuzzed_data_provider, 16));
}
CVectorWriter stream{0, golomb_rice_data, 0};
VectorWriter stream{golomb_rice_data, 0};
WriteCompactSize(stream, static_cast<uint32_t>(elements.size()));
BitStreamWriter<CVectorWriter> bitwriter(stream);
BitStreamWriter bitwriter{stream};
if (!elements.empty()) {
uint64_t last_value = 0;
for (const uint64_t value : BuildHashedSet(elements, static_cast<uint64_t>(elements.size()) * static_cast<uint64_t>(BASIC_FILTER_M))) {

View File

@@ -74,49 +74,49 @@ BOOST_AUTO_TEST_CASE(streams_vector_writer)
// point should yield the same results, even if the first test grew the
// vector.
CVectorWriter{INIT_PROTO_VERSION, vch, 0, a, b};
VectorWriter{vch, 0, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 0, a, b};
VectorWriter{vch, 0, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
vch.clear();
CVectorWriter{INIT_PROTO_VERSION, vch, 2, a, b};
VectorWriter{vch, 2, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 2, a, b};
VectorWriter{vch, 2, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
vch.clear();
vch.resize(5, 0);
CVectorWriter{INIT_PROTO_VERSION, vch, 2, a, b};
VectorWriter{vch, 2, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 2, a, b};
VectorWriter{vch, 2, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
vch.clear();
vch.resize(4, 0);
CVectorWriter{INIT_PROTO_VERSION, vch, 3, a, b};
VectorWriter{vch, 3, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 3, a, b};
VectorWriter{vch, 3, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
vch.clear();
vch.resize(4, 0);
CVectorWriter{INIT_PROTO_VERSION, vch, 4, a, b};
VectorWriter{vch, 4, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 4, a, b};
VectorWriter{vch, 4, a, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
vch.clear();
CVectorWriter{INIT_PROTO_VERSION, vch, 0, bytes};
VectorWriter{vch, 0, bytes};
BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 0, bytes};
VectorWriter{vch, 0, bytes};
BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
vch.clear();
vch.resize(4, 8);
CVectorWriter{INIT_PROTO_VERSION, vch, 2, a, bytes, b};
VectorWriter{vch, 2, a, bytes, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
CVectorWriter{INIT_PROTO_VERSION, vch, 2, a, bytes, b};
VectorWriter{vch, 2, a, bytes, b};
BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
vch.clear();
}