summaryrefslogtreecommitdiff
path: root/absl/container/internal/hashtablez_sampler.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-09-11 07:15:05 -0700
committerGravatar Derek Mauro <dmauro@google.com>2020-09-11 20:29:14 -0400
commit6af91b35109cb35ae53cfe908e31a0c31c4a47f3 (patch)
treea35e585f2378b1c9214516efc73bbf9dcebe56ce /absl/container/internal/hashtablez_sampler.h
parentf2c9c663db28a8a898c1fc8c8e06ab9b93eb5610 (diff)
Export of internal Abseil changes
-- 0e6d5abe305df4e943e0bc0256c67afc00956691 by Abseil Team <absl-team@google.com>: Ensure that Hashtablez does not pull in absl::Mutex dependency when turned off at compile time. PiperOrigin-RevId: 331142625 GitOrigin-RevId: 0e6d5abe305df4e943e0bc0256c67afc00956691 Change-Id: I984d6d3436e4825a7b20758c45b3142c0f3bb45a
Diffstat (limited to 'absl/container/internal/hashtablez_sampler.h')
-rw-r--r--absl/container/internal/hashtablez_sampler.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/absl/container/internal/hashtablez_sampler.h b/absl/container/internal/hashtablez_sampler.h
index b2a30c9a..394348da 100644
--- a/absl/container/internal/hashtablez_sampler.h
+++ b/absl/container/internal/hashtablez_sampler.h
@@ -139,6 +139,11 @@ inline void RecordEraseSlow(HashtablezInfo* info) {
HashtablezInfo* SampleSlow(int64_t* next_sample);
void UnsampleSlow(HashtablezInfo* info);
+#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
+#error ABSL_INTERNAL_HASHTABLEZ_SAMPLE cannot be directly set
+#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
+
+#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
class HashtablezInfoHandle {
public:
explicit HashtablezInfoHandle() : info_(nullptr) {}
@@ -190,9 +195,22 @@ class HashtablezInfoHandle {
friend class HashtablezInfoHandlePeer;
HashtablezInfo* info_;
};
+#else
+// Ensure that when Hashtablez is turned off at compile time, HashtablezInfo can
+// be removed by the linker, in order to reduce the binary size.
+class HashtablezInfoHandle {
+ public:
+ explicit HashtablezInfoHandle() = default;
+ explicit HashtablezInfoHandle(std::nullptr_t) {}
-#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
-#error ABSL_INTERNAL_HASHTABLEZ_SAMPLE cannot be directly set
+ inline void RecordStorageChanged(size_t /*size*/, size_t /*capacity*/) {}
+ inline void RecordRehash(size_t /*total_probe_length*/) {}
+ inline void RecordInsert(size_t /*hash*/, size_t /*distance_from_desired*/) {}
+ inline void RecordErase() {}
+
+ friend inline void swap(HashtablezInfoHandle& /*lhs*/,
+ HashtablezInfoHandle& /*rhs*/) {}
+};
#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)