From 04672c69a0df64bb2a62b231e383db3c7c68f506 Mon Sep 17 00:00:00 2001 From: Gennadiy Rozental Date: Tue, 4 Oct 2022 13:28:12 -0700 Subject: [PATCH] No changes in OSS. PiperOrigin-RevId: 478869244 Change-Id: Id16eb1e5036e95a5e2a990a647f1f7090129a009 --- absl/container/BUILD.bazel | 3 +++ absl/container/CMakeLists.txt | 3 +++ absl/container/internal/raw_hash_set_test.cc | 27 +++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 71afe9d2..15162f28 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -637,6 +637,8 @@ cc_test( ], deps = [ ":container_memory", + ":flat_hash_map", + ":flat_hash_set", ":hash_function_defaults", ":hash_policy_testing", ":hashtable_debug", @@ -646,6 +648,7 @@ cc_test( "//absl/base:core_headers", "//absl/base:prefetch", "//absl/base:raw_logging_internal", + "//absl/log", "//absl/strings", "@com_google_googletest//:gtest_main", ], diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index a3fdb969..6c2931b6 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt @@ -722,12 +722,15 @@ absl_cc_test( ${ABSL_TEST_COPTS} DEPS absl::container_memory + absl::flat_hash_map + absl::flat_hash_set absl::hash_function_defaults absl::hash_policy_testing absl::hashtable_debug absl::raw_hash_set absl::base absl::config + absl::log absl::core_headers absl::prefetch absl::raw_logging_internal diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index f77ffbc1..eec9da43 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -14,17 +14,25 @@ #include "absl/container/internal/raw_hash_set.h" +#include #include #include #include #include #include +#include +#include +#include #include #include +#include #include #include +#include #include #include +#include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -33,10 +41,13 @@ #include "absl/base/internal/cycleclock.h" #include "absl/base/internal/prefetch.h" #include "absl/base/internal/raw_logging.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" #include "absl/container/internal/container_memory.h" #include "absl/container/internal/hash_function_defaults.h" #include "absl/container/internal/hash_policy_testing.h" #include "absl/container/internal/hashtable_debug.h" +#include "absl/log/log.h" #include "absl/strings/string_view.h" namespace absl { @@ -339,7 +350,7 @@ class StringPolicy { struct ctor {}; template - slot_type(ctor, Ts&&... ts) : pair(std::forward(ts)...) {} + explicit slot_type(ctor, Ts&&... ts) : pair(std::forward(ts)...) {} std::pair pair; }; @@ -411,7 +422,7 @@ struct CustomAlloc : std::allocator { CustomAlloc() {} template - CustomAlloc(const CustomAlloc& other) {} + explicit CustomAlloc(const CustomAlloc& /*other*/) {} template struct rebind { using other = CustomAlloc; @@ -1275,6 +1286,7 @@ TEST(Table, DISABLED_EnsureNonQuadraticTopNXorSeedByProbeSeqLength) { for (size_t size : sizes) { auto& stat = stats[size]; VerifyStats(size, expected, stat); + LOG(INFO) << size << " " << stat; } } @@ -1370,6 +1382,7 @@ TEST(Table, DISABLED_EnsureNonQuadraticTopNLinearTransformByProbeSeqLength) { for (size_t size : sizes) { auto& stat = stats[size]; VerifyStats(size, expected, stat); + LOG(INFO) << size << " " << stat; } } @@ -1504,7 +1517,7 @@ TEST(Table, RehashZeroForcesRehash) { TEST(Table, ConstructFromInitList) { using P = std::pair; struct Q { - operator P() const { return {}; } + operator P() const { return {}; } // NOLINT }; StringTable t = {P(), Q(), {}, {{}, {}}}; } @@ -2027,7 +2040,7 @@ TEST(Table, UnstablePointers) { TEST(TableDeathTest, EraseOfEndAsserts) { // Use an assert with side-effects to figure out if they are actually enabled. bool assert_enabled = false; - assert([&]() { + assert([&]() { // NOLINT assert_enabled = true; return true; }()); @@ -2047,7 +2060,7 @@ TEST(RawHashSamplerTest, Sample) { auto& sampler = GlobalHashtablezSampler(); size_t start_size = 0; - std::unordered_set preexisting_info; + absl::flat_hash_set preexisting_info; start_size += sampler.Iterate([&](const HashtablezInfo& info) { preexisting_info.insert(&info); ++start_size; @@ -2074,8 +2087,8 @@ TEST(RawHashSamplerTest, Sample) { } } size_t end_size = 0; - std::unordered_map observed_checksums; - std::unordered_map reservations; + absl::flat_hash_map observed_checksums; + absl::flat_hash_map reservations; end_size += sampler.Iterate([&](const HashtablezInfo& info) { if (preexisting_info.count(&info) == 0) { observed_checksums[info.hashes_bitwise_xor.load(