diff --git a/tdutils/td/utils/FlatHashMap.h b/tdutils/td/utils/FlatHashMap.h index 3e8f7688f906..6ea919a476c0 100644 --- a/tdutils/td/utils/FlatHashMap.h +++ b/tdutils/td/utils/FlatHashMap.h @@ -17,7 +17,7 @@ namespace td { template , class EqT = std::equal_to> -using FlatHashMap = FlatHashTable, HashT, EqT>; +using FlatHashMap = FlatHashTable, HashT, EqT>; //using FlatHashMap = FlatHashMapChunks; //using FlatHashMap = std::unordered_map; diff --git a/tdutils/td/utils/FlatHashMapChunks.h b/tdutils/td/utils/FlatHashMapChunks.h index cd8e73f2725f..c5fcf4a32878 100644 --- a/tdutils/td/utils/FlatHashMapChunks.h +++ b/tdutils/td/utils/FlatHashMapChunks.h @@ -257,7 +257,7 @@ class FlatHashTableChunks { } Iterator find(const KeyT &key) { - if (empty() || is_hash_table_key_empty(key)) { + if (empty() || is_hash_table_key_empty(key)) { return end(); } const auto hash = calc_hash(key); @@ -326,7 +326,7 @@ class FlatHashTableChunks { template std::pair emplace(KeyT key, ArgsT &&...args) { - CHECK(!is_hash_table_key_empty(key)); + CHECK(!is_hash_table_key_empty(key)); auto it = find(key); if (it != end()) { return {it, false}; @@ -562,10 +562,10 @@ class FlatHashTableChunks { }; template , class EqT = std::equal_to> -using FlatHashMapChunks = FlatHashTableChunks, HashT, EqT>; +using FlatHashMapChunks = FlatHashTableChunks, HashT, EqT>; template , class EqT = std::equal_to> -using FlatHashSetChunks = FlatHashTableChunks, HashT, EqT>; +using FlatHashSetChunks = FlatHashTableChunks, HashT, EqT>; template void table_remove_if(FlatHashTableChunks &table, FuncT &&func) { diff --git a/tdutils/td/utils/FlatHashSet.h b/tdutils/td/utils/FlatHashSet.h index 96bb1928611c..ca4398fd5dd2 100644 --- a/tdutils/td/utils/FlatHashSet.h +++ b/tdutils/td/utils/FlatHashSet.h @@ -17,7 +17,7 @@ namespace td { template , class EqT = std::equal_to> -using FlatHashSet = FlatHashTable, HashT, EqT>; +using FlatHashSet = FlatHashTable, HashT, EqT>; //using FlatHashSet = FlatHashSetChunks; //using FlatHashSet = std::unordered_set; diff --git a/tdutils/td/utils/FlatHashTable.h b/tdutils/td/utils/FlatHashTable.h index f818cbea7784..f2af44b86a34 100644 --- a/tdutils/td/utils/FlatHashTable.h +++ b/tdutils/td/utils/FlatHashTable.h @@ -308,7 +308,7 @@ class FlatHashTable { template std::pair emplace(KeyT key, ArgsT &&...args) { - CHECK(!is_hash_table_key_empty(key)); + CHECK(!is_hash_table_key_empty(key)); if (unlikely(bucket_count_mask_ == 0)) { CHECK(used_node_count_ == 0); resize(8); @@ -447,7 +447,7 @@ class FlatHashTable { } NodeT *find_impl(const KeyT &key) { - if (unlikely(nodes_ == nullptr) || is_hash_table_key_empty(key)) { + if (unlikely(nodes_ == nullptr) || is_hash_table_key_empty(key)) { return nullptr; } auto bucket = calc_bucket(key); diff --git a/tdutils/td/utils/HashTableUtils.h b/tdutils/td/utils/HashTableUtils.h index 620796d44328..21d4104daf4c 100644 --- a/tdutils/td/utils/HashTableUtils.h +++ b/tdutils/td/utils/HashTableUtils.h @@ -13,9 +13,9 @@ namespace td { -template +template bool is_hash_table_key_empty(const KeyT &key) { - return key == KeyT(); + return EqT()(key, KeyT()); } inline uint32 randomize_hash(uint32 h) { diff --git a/tdutils/td/utils/MapNode.h b/tdutils/td/utils/MapNode.h index d75c8e86b54c..9d87aad8291b 100644 --- a/tdutils/td/utils/MapNode.h +++ b/tdutils/td/utils/MapNode.h @@ -15,7 +15,7 @@ namespace td { -template +template struct MapNode { using first_type = KeyT; using second_type = ValueT; @@ -72,7 +72,7 @@ struct MapNode { } bool empty() const { - return is_hash_table_key_empty(first); + return is_hash_table_key_empty(first); } void clear() { @@ -91,8 +91,8 @@ struct MapNode { } }; -template -struct MapNode 28 * sizeof(void *))>> { +template +struct MapNode 28 * sizeof(void *))>> { struct Impl { using first_type = KeyT; using second_type = ValueT; @@ -105,7 +105,7 @@ struct MapNode Impl(InputKeyT &&key, ArgsT &&...args) : first(std::forward(key)) { new (&second) ValueT(std::forward(args)...); - DCHECK(!is_hash_table_key_empty(first)); + DCHECK(!is_hash_table_key_empty(first)); } Impl(const Impl &) = delete; Impl &operator=(const Impl &) = delete; diff --git a/tdutils/td/utils/SetNode.h b/tdutils/td/utils/SetNode.h index 35e525cfce04..a637a8366f13 100644 --- a/tdutils/td/utils/SetNode.h +++ b/tdutils/td/utils/SetNode.h @@ -14,7 +14,7 @@ namespace td { -template +template struct SetNode { using public_key_type = KeyT; using public_type = const KeyT; @@ -54,7 +54,7 @@ struct SetNode { } bool empty() const { - return is_hash_table_key_empty(first); + return is_hash_table_key_empty(first); } void clear() { @@ -67,8 +67,8 @@ struct SetNode { } }; -template -struct SetNode 28 * sizeof(void *))>> { +template +struct SetNode 28 * sizeof(void *))>> { struct Impl { using second_type = KeyT; @@ -76,7 +76,7 @@ struct SetNode 28 * sizeof(void template explicit Impl(InputKeyT &&key) : first(std::forward(key)) { - DCHECK(!is_hash_table_key_empty(first)); + DCHECK(!is_hash_table_key_empty(first)); } Impl(const Impl &) = delete; Impl &operator=(const Impl &) = delete; diff --git a/tdutils/test/hashset_benchmark.cpp b/tdutils/test/hashset_benchmark.cpp index f066f94cbb2b..35e1ae5a5e46 100644 --- a/tdutils/test/hashset_benchmark.cpp +++ b/tdutils/test/hashset_benchmark.cpp @@ -590,7 +590,7 @@ BENCHMARK_TEMPLATE(BM_mask, td::MaskSse2); #endif template , class EqT = std::equal_to> -using FlatHashMapImpl = td::FlatHashTable, HashT, EqT>; +using FlatHashMapImpl = td::FlatHashTable, HashT, EqT>; #define FOR_EACH_TABLE(F) \ F(FlatHashMapImpl) \