diff --git a/tdutils/td/utils/FlatHashMap.h b/tdutils/td/utils/FlatHashMap.h index 097d02939..c1bd4ef47 100644 --- a/tdutils/td/utils/FlatHashMap.h +++ b/tdutils/td/utils/FlatHashMap.h @@ -14,13 +14,13 @@ namespace td { template , class EqT = std::equal_to> -//using FlatHashMap = FlatHashMapImpl; -using FlatHashMap = FlatHashMapChunks; +using FlatHashMap = FlatHashMapImpl; +//using FlatHashMap = FlatHashMapChunks; //using FlatHashMap = std::unordered_map; template , class EqT = std::equal_to> -//using FlatHashSet = FlatHashSetImpl; -using FlatHashSet = FlatHashSetChunks; +using FlatHashSet = FlatHashSetImpl; +//using FlatHashSet = FlatHashSetChunks; //using FlatHashSet = std::unordered_set; } // namespace td diff --git a/tdutils/td/utils/FlatHashMapChunks.h b/tdutils/td/utils/FlatHashMapChunks.h index cac0d238b..05aab59fd 100644 --- a/tdutils/td/utils/FlatHashMapChunks.h +++ b/tdutils/td/utils/FlatHashMapChunks.h @@ -243,10 +243,9 @@ class FlatHashTableChunks { return *this; } void swap(FlatHashTableChunks &other) noexcept { - using std::swap; - swap(nodes_, other.nodes_); - swap(chunks_, other.chunks_); - swap(used_nodes_, other.used_nodes_); + nodes_.swap(other.nodes_); + chunks_.swap(other.chunks_); + std::swap(used_nodes_, other.used_nodes_); } ~FlatHashTableChunks() = default; @@ -493,7 +492,7 @@ class FlatHashTableChunks { CHECK(new_size >= Chunk::CHUNK_SIZE); fixed_vector old_nodes(new_size); fixed_vector chunks(new_size / Chunk::CHUNK_SIZE); - std::swap(old_nodes, nodes_); + old_nodes.swap(nodes_); chunks_ = std::move(chunks); used_nodes_ = 0; diff --git a/tdutils/td/utils/FlatHashMapLinear.h b/tdutils/td/utils/FlatHashMapLinear.h index 3caf7e94d..d82f6c558 100644 --- a/tdutils/td/utils/FlatHashMapLinear.h +++ b/tdutils/td/utils/FlatHashMapLinear.h @@ -287,9 +287,8 @@ class FlatHashTable { return *this; } void swap(FlatHashTable &other) noexcept { - using std::swap; - swap(nodes_, other.nodes_); - swap(used_nodes_, other.used_nodes_); + nodes_.swap(other.nodes_); + std::swap(used_nodes_, other.used_nodes_); } ~FlatHashTable() = default; @@ -496,7 +495,7 @@ class FlatHashTable { void resize(size_t new_size) { fixed_vector old_nodes(new_size); - std::swap(old_nodes, nodes_); + old_nodes.swap(nodes_); for (auto &old_node : old_nodes) { if (old_node.empty()) { diff --git a/tdutils/td/utils/fixed_vector.h b/tdutils/td/utils/fixed_vector.h index 0ee720d3c..a4bf0af79 100644 --- a/tdutils/td/utils/fixed_vector.h +++ b/tdutils/td/utils/fixed_vector.h @@ -71,4 +71,9 @@ class fixed_vector { size_t size_{0}; }; +template +void swap(fixed_vector &lhs, fixed_vector &rhs) { + lhs.swap(rhs); +} + } // namespace td