summaryrefslogtreecommitdiff
path: root/absl/container/internal/raw_hash_set.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container/internal/raw_hash_set.cc')
-rw-r--r--absl/container/internal/raw_hash_set.cc33
1 files changed, 16 insertions, 17 deletions
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc
index 37d7e487..1ccee1ed 100644
--- a/absl/container/internal/raw_hash_set.cc
+++ b/absl/container/internal/raw_hash_set.cc
@@ -15,7 +15,6 @@
#include "absl/container/internal/raw_hash_set.h"
#include <atomic>
-#include <cassert>
#include <cstddef>
#include <cstring>
@@ -131,8 +130,8 @@ static inline void* PrevSlot(void* slot, size_t slot_size) {
void DropDeletesWithoutResize(CommonFields& common,
const PolicyFunctions& policy, void* tmp_space) {
void* set = &common;
- void* slot_array = common.slots();
- const size_t capacity = common.capacity();
+ void* slot_array = common.slots_;
+ const size_t capacity = common.capacity_;
assert(IsValidCapacity(capacity));
assert(!is_small(capacity));
// Algorithm:
@@ -151,7 +150,7 @@ void DropDeletesWithoutResize(CommonFields& common,
// swap current element with target element
// mark target as FULL
// repeat procedure for current slot with moved from element (target)
- ctrl_t* ctrl = common.control();
+ ctrl_t* ctrl = common.control_;
ConvertDeletedToEmptyAndFullToDeleted(ctrl, capacity);
auto hasher = policy.hash_slot;
auto transfer = policy.transfer;
@@ -211,11 +210,11 @@ void DropDeletesWithoutResize(CommonFields& common,
void EraseMetaOnly(CommonFields& c, ctrl_t* it, size_t slot_size) {
assert(IsFull(*it) && "erasing a dangling iterator");
- c.set_size(c.size() - 1);
- const auto index = static_cast<size_t>(it - c.control());
- const size_t index_before = (index - Group::kWidth) & c.capacity();
+ --c.size_;
+ const auto index = static_cast<size_t>(it - c.control_);
+ const size_t index_before = (index - Group::kWidth) & c.capacity_;
const auto empty_after = Group(it).MaskEmpty();
- const auto empty_before = Group(c.control() + index_before).MaskEmpty();
+ const auto empty_before = Group(c.control_ + index_before).MaskEmpty();
// We count how many consecutive non empties we have to the right and to the
// left of `it`. If the sum is >= kWidth then there is at least one probe
@@ -227,26 +226,26 @@ void EraseMetaOnly(CommonFields& c, ctrl_t* it, size_t slot_size) {
SetCtrl(c, index, was_never_full ? ctrl_t::kEmpty : ctrl_t::kDeleted,
slot_size);
- c.set_growth_left(c.growth_left() + (was_never_full ? 1 : 0));
+ c.growth_left() += (was_never_full ? 1 : 0);
c.infoz().RecordErase();
}
void ClearBackingArray(CommonFields& c, const PolicyFunctions& policy,
bool reuse) {
- c.set_size(0);
+ c.size_ = 0;
if (reuse) {
ResetCtrl(c, policy.slot_size);
- c.infoz().RecordStorageChanged(0, c.capacity());
+ c.infoz().RecordStorageChanged(0, c.capacity_);
} else {
void* set = &c;
- (*policy.dealloc)(set, policy, c.control(), c.slots(), c.capacity());
- c.set_control(EmptyGroup());
+ (*policy.dealloc)(set, policy, c.control_, c.slots_, c.capacity_);
+ c.control_ = EmptyGroup();
c.set_generation_ptr(EmptyGeneration());
- c.set_slots(nullptr);
- c.set_capacity(0);
- c.set_growth_left(0);
+ c.slots_ = nullptr;
+ c.capacity_ = 0;
+ c.growth_left() = 0;
c.infoz().RecordClearedReservation();
- assert(c.size() == 0);
+ assert(c.size_ == 0);
c.infoz().RecordStorageChanged(0, 0);
}
}