summaryrefslogtreecommitdiff
path: root/absl/container/internal/raw_hash_set.cc
diff options
context:
space:
mode:
authorGravatar Evan Brown <ezb@google.com>2022-12-08 09:35:09 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2022-12-08 09:35:51 -0800
commit523b86994f1e705e27e99cdf6527ec1f010e69d1 (patch)
tree834aee1d5eb1056631928c06ced0f0702f504f91 /absl/container/internal/raw_hash_set.cc
parent2e17768541d7caa0da88e774f916b012ffc57ebb (diff)
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
Diffstat (limited to 'absl/container/internal/raw_hash_set.cc')
-rw-r--r--absl/container/internal/raw_hash_set.cc17
1 files changed, 8 insertions, 9 deletions
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<void*>(reinterpret_cast<uintptr_t>(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<size_t>(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);