Fix formatting.

This commit is contained in:
levlam 2022-02-12 00:48:35 +03:00
parent a11d37dd4c
commit 512c0cd3c2
4 changed files with 15 additions and 14 deletions

View File

@ -7,6 +7,7 @@
#include "td/utils/FlatHashMap.h"
#include <absl/container/flat_hash_map.h>
#include <array>
#include <folly/container/F14Map.h>
#include <map>
#include <unordered_map>

View File

@ -14,7 +14,6 @@
#include <initializer_list>
#include <iterator>
#include <new>
#include <unordered_map>
#include <utility>
namespace td {
@ -585,10 +584,8 @@ using FlatHashSetImpl = FlatHashTable<SetNode<KeyT>, HashT, EqT>;
template <class KeyT, class ValueT, class HashT = std::hash<KeyT>, class EqT = std::equal_to<KeyT>>
using FlatHashMap = FlatHashMapImpl<KeyT, ValueT, HashT, EqT>;
//using FlatHashMap = std::unordered_map<KeyT, ValueT, HashT, EqT>;
template <class KeyT, class HashT = std::hash<KeyT>, class EqT = std::equal_to<KeyT>>
using FlatHashSet = FlatHashSetImpl<KeyT, HashT, EqT>;
//using FlatHashSet = std::unordered_set<KeyT, HashT, EqT>;
} // namespace td

View File

@ -25,15 +25,15 @@ static auto extract_kv(const T &reference) {
TEST(FlatHashMap, basic) {
{
td::FlatHashSet<int> s;
s.insert(5);
for (auto x : s) {
}
int N = 100000;
for (int i = 0; i < 10000000; i++) {
s.insert((i + N/2)%N);
s.erase(i%N);
}
td::FlatHashSet<int> s;
s.insert(5);
for (auto x : s) {
}
int N = 100000;
for (int i = 0; i < 10000000; i++) {
s.insert((i + N / 2) % N);
s.erase(i % N);
}
}
{
td::FlatHashMap<int, int> map;

View File

@ -248,7 +248,7 @@ static void BM_emplace_same(benchmark::State &state) {
while (state.KeepRunningBatch(BATCH_SIZE)) {
for (size_t i = 0; i < BATCH_SIZE; i++) {
benchmark::DoNotOptimize(table.emplace(key + (i & 15) * 100 , 43784932));
benchmark::DoNotOptimize(table.emplace(key + (i & 15) * 100, 43784932));
}
}
}
@ -383,7 +383,10 @@ static void BM_remove_if_slow(benchmark::State &state) {
auto first_key = table.begin()->first;
{
size_t cnt = 0;
td::table_remove_if(table, [&cnt](auto &) { cnt += 2; return cnt <= N; });
td::table_remove_if(table, [&cnt](auto &) {
cnt += 2;
return cnt <= N;
});
}
while (state.KeepRunningBatch(BATCH_SIZE)) {
for (size_t i = 0; i < BATCH_SIZE; i++) {