Commit 523b8699 by Evan Brown Committed by Copybara-Service

Change CommonFields from a private base class of raw_hash_set to be the first…

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
parent 2e177685
...@@ -90,7 +90,7 @@ static inline void* PrevSlot(void* slot, size_t slot_size) { ...@@ -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); 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) { const PolicyFunctions& policy, void* tmp_space) {
void* set = &common; void* set = &common;
void* slot_array = common.slots_; void* slot_array = common.slots_;
...@@ -167,12 +167,11 @@ void DropDeletesWithoutResize(CommonFields& common, size_t& growth_left, ...@@ -167,12 +167,11 @@ void DropDeletesWithoutResize(CommonFields& common, size_t& growth_left,
slot_ptr = PrevSlot(slot_ptr, slot_size); slot_ptr = PrevSlot(slot_ptr, slot_size);
} }
} }
ResetGrowthLeft(common, growth_left); ResetGrowthLeft(common);
common.infoz().RecordRehash(total_probe_length); common.infoz().RecordRehash(total_probe_length);
} }
void EraseMetaOnly(CommonFields& c, size_t& growth_left, ctrl_t* it, void EraseMetaOnly(CommonFields& c, ctrl_t* it, size_t slot_size) {
size_t slot_size) {
assert(IsFull(*it) && "erasing a dangling iterator"); assert(IsFull(*it) && "erasing a dangling iterator");
--c.size_; --c.size_;
const auto index = static_cast<size_t>(it - c.control_); 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, ...@@ -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, SetCtrl(c, index, was_never_full ? ctrl_t::kEmpty : ctrl_t::kDeleted,
slot_size); slot_size);
growth_left += (was_never_full ? 1 : 0); c.growth_left_ += (was_never_full ? 1 : 0);
c.infoz().RecordErase(); c.infoz().RecordErase();
} }
void ClearBackingArray(CommonFields& c, size_t& growth_left, void ClearBackingArray(CommonFields& c, const PolicyFunctions& policy,
const PolicyFunctions& policy, bool reuse) { bool reuse) {
if (reuse) { if (reuse) {
c.size_ = 0; c.size_ = 0;
ResetCtrl(c, growth_left, policy.slot_size); ResetCtrl(c, policy.slot_size);
c.infoz().RecordStorageChanged(0, c.capacity_); c.infoz().RecordStorageChanged(0, c.capacity_);
} else { } else {
void* set = &c; void* set = &c;
...@@ -207,7 +206,7 @@ void ClearBackingArray(CommonFields& c, size_t& growth_left, ...@@ -207,7 +206,7 @@ void ClearBackingArray(CommonFields& c, size_t& growth_left,
c.slots_ = nullptr; c.slots_ = nullptr;
c.size_ = 0; c.size_ = 0;
c.capacity_ = 0; c.capacity_ = 0;
growth_left = 0; c.growth_left_ = 0;
c.infoz().RecordClearedReservation(); c.infoz().RecordClearedReservation();
assert(c.size_ == 0); assert(c.size_ == 0);
c.infoz().RecordStorageChanged(0, 0); c.infoz().RecordStorageChanged(0, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment