From b3a784f4ba5a0733efebcf528d703215e0244d58 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 23 Feb 2022 15:58:12 +0300 Subject: [PATCH] Properly clear other hashmap after move. --- tdutils/td/utils/FlatHashMapLinear.h | 4 ++-- tdutils/test/hashset_benchmark.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tdutils/td/utils/FlatHashMapLinear.h b/tdutils/td/utils/FlatHashMapLinear.h index ce47fc528..678dd3d4f 100644 --- a/tdutils/td/utils/FlatHashMapLinear.h +++ b/tdutils/td/utils/FlatHashMapLinear.h @@ -275,12 +275,12 @@ class FlatHashTable { } FlatHashTable(FlatHashTable &&other) noexcept : nodes_(std::move(other.nodes_)), used_nodes_(other.used_nodes_) { - other.used_nodes_ = 0; + other.clear(); } void operator=(FlatHashTable &&other) noexcept { nodes_ = std::move(other.nodes_); used_nodes_ = other.used_nodes_; - other.used_nodes_ = 0; + other.clear(); } void swap(FlatHashTable &other) noexcept { nodes_.swap(other.nodes_); diff --git a/tdutils/test/hashset_benchmark.cpp b/tdutils/test/hashset_benchmark.cpp index 6b73233af..41dea3eeb 100644 --- a/tdutils/test/hashset_benchmark.cpp +++ b/tdutils/test/hashset_benchmark.cpp @@ -435,8 +435,7 @@ static void benchmark_create(td::Slice name) { table.emplace(rnd(), i); } auto end = td::Timestamp::now(); - LOG(INFO) << name << ":" - << "create " << N << " elements: " << td::format::as_time(end.at() - start.at()); + LOG(INFO) << name << ": create " << N << " elements: " << td::format::as_time(end.at() - start.at()); double res = 0; td::vector> pauses; @@ -451,8 +450,8 @@ static void benchmark_create(td::Slice name) { } } - LOG(INFO) << name << ":" - << "create another " << N << " elements, max pause = " << td::format::as_time(res) << " " << pauses; + LOG(INFO) << name << ": create another " << N << " elements, max pause = " << td::format::as_time(res) << " " + << pauses; } } @@ -559,8 +558,8 @@ BENCHMARK_TEMPLATE(BM_mask, td::MaskSse2); #endif #define FOR_EACH_TABLE(F) \ - F(td::FlatHashMapChunks) \ F(td::FlatHashMapImpl) \ + F(td::FlatHashMapChunks) \ F(folly::F14FastMap) \ F(absl::flat_hash_map) \ F(std::unordered_map) \