Skip to content

Commit 415dccb

Browse files
ezbrcopybara-github
authored andcommitted
Refactor: call AssertIsFull from iterator::assert_is_full to avoid passing the same arguments repeatedly.
PiperOrigin-RevId: 782015933 Change-Id: I46042e1163078449e3ca59f8264e709902578961
1 parent f6bd67a commit 415dccb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

absl/container/internal/raw_hash_set.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,19 +1991,19 @@ class raw_hash_set {
19911991

19921992
// PRECONDITION: not an end() iterator.
19931993
reference operator*() const {
1994-
AssertIsFull(ctrl_, generation(), generation_ptr(), "operator*()");
1994+
assert_is_full("operator*()");
19951995
return unchecked_deref();
19961996
}
19971997

19981998
// PRECONDITION: not an end() iterator.
19991999
pointer operator->() const {
2000-
AssertIsFull(ctrl_, generation(), generation_ptr(), "operator->");
2000+
assert_is_full("operator->");
20012001
return &operator*();
20022002
}
20032003

20042004
// PRECONDITION: not an end() iterator.
20052005
iterator& operator++() {
2006-
AssertIsFull(ctrl_, generation(), generation_ptr(), "operator++");
2006+
assert_is_full("operator++");
20072007
++ctrl_;
20082008
++slot_;
20092009
skip_empty_or_deleted();
@@ -2054,6 +2054,10 @@ class raw_hash_set {
20542054
explicit iterator(const GenerationType* generation_ptr)
20552055
: HashSetIteratorGenerationInfo(generation_ptr), ctrl_(nullptr) {}
20562056

2057+
void assert_is_full(const char* operation) const {
2058+
AssertIsFull(ctrl_, generation(), generation_ptr(), operation);
2059+
}
2060+
20572061
// Fixes up `ctrl_` to point to a full or sentinel by advancing `ctrl_` and
20582062
// `slot_` until they reach one.
20592063
void skip_empty_or_deleted() {
@@ -2685,7 +2689,7 @@ class raw_hash_set {
26852689
void erase(iterator it) {
26862690
ABSL_SWISSTABLE_ASSERT(capacity() > 0);
26872691
AssertNotDebugCapacity();
2688-
AssertIsFull(it.control(), it.generation(), it.generation_ptr(), "erase()");
2692+
it.assert_is_full("erase()");
26892693
destroy(it.slot());
26902694
erase_meta_only(it);
26912695
}
@@ -2751,8 +2755,7 @@ class raw_hash_set {
27512755

27522756
node_type extract(const_iterator position) {
27532757
AssertNotDebugCapacity();
2754-
AssertIsFull(position.control(), position.inner_.generation(),
2755-
position.inner_.generation_ptr(), "extract()");
2758+
position.inner_.assert_is_full("extract()");
27562759
allocator_type alloc(char_alloc_ref());
27572760
auto node = CommonAccess::Transfer<node_type>(alloc, position.slot());
27582761
erase_meta_only(position);

0 commit comments

Comments
 (0)