diff --git a/src/function/list_group.cc b/src/function/list_group.cc index 70f9460..c577528 100644 --- a/src/function/list_group.cc +++ b/src/function/list_group.cc @@ -34,7 +34,7 @@ U32ListStruct GroupIndex(KList keys, void *exec_context) { result.data = reinterpret_cast(exec_ctx->arena.Allocate(sizeof(uint32_t) * keys.len)); std::unordered_map table; - table.reserve(keys.len * 2); + table.reserve(keys.len); uint32_t next_id = 0; for (uint32_t i = 0; i < keys.len; ++i) { auto [it, inserted] = table.try_emplace(keys.data[i], next_id); @@ -53,7 +53,7 @@ U32ListStruct GroupIndexString(StringListStruct keys, void *exec_context) { result.data = reinterpret_cast(exec_ctx->arena.Allocate(sizeof(uint32_t) * keys.len)); std::unordered_map table; - table.reserve(static_cast(keys.len) * 2); + table.reserve(static_cast(keys.len)); uint32_t next_id = 0; for (uint32_t i = 0; i < keys.len; ++i) { std::string_view sv(keys.data[i].data, keys.data[i].len); diff --git a/src/function/list_indexing.cc b/src/function/list_indexing.cc index 39318a6..f92262c 100644 --- a/src/function/list_indexing.cc +++ b/src/function/list_indexing.cc @@ -31,7 +31,7 @@ template void *BuildLookupTableInt(KList b, void *exec_context) { auto *exec_ctx = reinterpret_cast(exec_context); IntLookupTable seed; - seed.reserve(static_cast(b.len) * 2); + seed.reserve(static_cast(b.len)); for (uint32_t j = 0; j < b.len; ++j) { seed.try_emplace(b.data[j], j); } @@ -41,7 +41,7 @@ void *BuildLookupTableInt(KList b, void *exec_context) { void *BuildLookupTableString(StringListStruct b, void *exec_context) { auto *exec_ctx = reinterpret_cast(exec_context); StringLookupTable seed; - seed.reserve(static_cast(b.len) * 2); + seed.reserve(static_cast(b.len)); for (uint32_t j = 0; j < b.len; ++j) { std::string_view sv(b.data[j].data, b.data[j].len); seed.try_emplace(sv, j);