From 581b904507eca5bc145de595a7347fcfb80f28b4 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 23 Jan 2023 16:33:26 +0000 Subject: Use const ref to reduce code bloat. --- .../unique_store_string_allocator_test.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp b/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp index e865239787b..64e0c1599bd 100644 --- a/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp +++ b/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include using namespace vespalib::datastore; @@ -29,12 +28,12 @@ template > struct TestBase : public ::testing::Test { using EntryRefType = RefT; - AllocStats stats; + AllocStats allocStats; UniqueStoreStringAllocator allocator; generation_t generation; TestBase() - : stats(), - allocator(std::make_unique(stats)), + : allocStats(), + allocator(std::make_unique(allocStats)), generation(1) {} void assert_add(const char *input) { @@ -61,11 +60,12 @@ struct TestBase : public ::testing::Test { return allocator.get_data_store().getBufferState(get_buffer_id(ref)); } void assert_buffer_state(EntryRef ref, const TestBufferStats expStats) const { + const auto & stats = buffer_state(ref).stats(); EXPECT_EQ(expStats._used, buffer_state(ref).size()); - EXPECT_EQ(expStats._hold, buffer_state(ref).stats().hold_elems()); - EXPECT_EQ(expStats._dead, buffer_state(ref).stats().dead_elems()); - EXPECT_EQ(expStats._extra_used, buffer_state(ref).stats().extra_used_bytes()); - EXPECT_EQ(expStats._extra_hold, buffer_state(ref).stats().extra_hold_bytes()); + EXPECT_EQ(expStats._hold, stats.hold_elems()); + EXPECT_EQ(expStats._dead, stats.dead_elems()); + EXPECT_EQ(expStats._extra_used, stats.extra_used_bytes()); + EXPECT_EQ(expStats._extra_hold, stats.extra_hold_bytes()); } void reclaim_memory() { allocator.get_data_store().assign_generation(generation++); @@ -179,7 +179,7 @@ TEST_F(StringTest, free_list_is_never_used_for_move_on_compact) TEST_F(StringTest, provided_memory_allocator_is_used) { - EXPECT_EQ(AllocStats(18, 0), stats); + EXPECT_EQ(AllocStats(18, 0), allocStats); } TEST_F(SmallOffsetStringTest, new_underlying_buffer_is_allocated_when_current_is_full) @@ -196,7 +196,7 @@ TEST_F(SmallOffsetStringTest, new_underlying_buffer_is_allocated_when_current_is uint32_t buffer_id = get_buffer_id(add(small.c_str())); EXPECT_EQ(second_buffer_id, buffer_id); } - EXPECT_LT(18, stats.alloc_cnt); + EXPECT_LT(18, allocStats.alloc_cnt); } GTEST_MAIN_RUN_ALL_TESTS() -- cgit v1.2.3