From 523b86994f1e705e27e99cdf6527ec1f010e69d1 Mon Sep 17 00:00:00 2001 From: Evan Brown Date: Thu, 8 Dec 2022 09:35:09 -0800 Subject: Change CommonFields from a private base class of raw_hash_set to be the first member of the settings_ CompressedTuple so that we can move growth_left into CommonFields. This allows for removing growth_left as a separate argument for a few functions. Also, move the infoz() accessor functions to be before the data members of CommonFields to comply with the style guide. PiperOrigin-RevId: 493918310 Change-Id: I58474e37d3b16a1513d2931af6b153dea1d809c2 --- absl/container/internal/raw_hash_set.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'absl/container/internal/raw_hash_set.cc') diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc index fae12793..1beab92f 100644 --- a/absl/container/internal/raw_hash_set.cc +++ b/absl/container/internal/raw_hash_set.cc @@ -90,7 +90,7 @@ static inline void* PrevSlot(void* slot, size_t slot_size) { return reinterpret_cast(reinterpret_cast(slot) - slot_size); } -void DropDeletesWithoutResize(CommonFields& common, size_t& growth_left, +void DropDeletesWithoutResize(CommonFields& common, const PolicyFunctions& policy, void* tmp_space) { void* set = &common; void* slot_array = common.slots_; @@ -167,12 +167,11 @@ void DropDeletesWithoutResize(CommonFields& common, size_t& growth_left, slot_ptr = PrevSlot(slot_ptr, slot_size); } } - ResetGrowthLeft(common, growth_left); + ResetGrowthLeft(common); common.infoz().RecordRehash(total_probe_length); } -void EraseMetaOnly(CommonFields& c, size_t& growth_left, ctrl_t* it, - size_t slot_size) { +void EraseMetaOnly(CommonFields& c, ctrl_t* it, size_t slot_size) { assert(IsFull(*it) && "erasing a dangling iterator"); --c.size_; const auto index = static_cast(it - c.control_); @@ -190,15 +189,15 @@ void EraseMetaOnly(CommonFields& c, size_t& growth_left, ctrl_t* it, SetCtrl(c, index, was_never_full ? ctrl_t::kEmpty : ctrl_t::kDeleted, slot_size); - growth_left += (was_never_full ? 1 : 0); + c.growth_left_ += (was_never_full ? 1 : 0); c.infoz().RecordErase(); } -void ClearBackingArray(CommonFields& c, size_t& growth_left, - const PolicyFunctions& policy, bool reuse) { +void ClearBackingArray(CommonFields& c, const PolicyFunctions& policy, + bool reuse) { if (reuse) { c.size_ = 0; - ResetCtrl(c, growth_left, policy.slot_size); + ResetCtrl(c, policy.slot_size); c.infoz().RecordStorageChanged(0, c.capacity_); } else { void* set = &c; @@ -207,7 +206,7 @@ void ClearBackingArray(CommonFields& c, size_t& growth_left, c.slots_ = nullptr; c.size_ = 0; c.capacity_ = 0; - growth_left = 0; + c.growth_left_ = 0; c.infoz().RecordClearedReservation(); assert(c.size_ == 0); c.infoz().RecordStorageChanged(0, 0); -- cgit v1.2.3