Skip to content

Commit 118924e

Browse files
ezbrcopybara-github
authored andcommitted
Refactor: move iterator unchecked_* members before data members to comply with Google C++ style guide.
Also make unchecked_equals members `const`. PiperOrigin-RevId: 781877490 Change-Id: I0bf5018f081a7a26e11fc67f3c344988b44a3ef3
1 parent 6cd1763 commit 118924e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

absl/container/internal/raw_hash_set.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,18 @@ class raw_hash_set {
20822082
}
20832083
}
20842084

2085+
// An equality check which skips ABSL Hardening iterator invalidation
2086+
// checks.
2087+
// Should be used when the lifetimes of the iterators are well-enough
2088+
// understood to prove that they cannot be invalid.
2089+
bool unchecked_equals(const iterator& b) const {
2090+
return ctrl_ == b.control();
2091+
}
2092+
2093+
// Dereferences the iterator without ABSL Hardening iterator invalidation
2094+
// checks.
2095+
reference unchecked_deref() const { return PolicyTraits::element(slot_); }
2096+
20852097
ctrl_t* control() const { return ctrl_; }
20862098
slot_type* slot() const { return slot_; }
20872099

@@ -2093,16 +2105,6 @@ class raw_hash_set {
20932105
union {
20942106
slot_type* slot_;
20952107
};
2096-
2097-
// An equality check which skips ABSL Hardening iterator invalidation
2098-
// checks.
2099-
// Should be used when the lifetimes of the iterators are well-enough
2100-
// understood to prove that they cannot be invalid.
2101-
bool unchecked_equals(const iterator& b) { return ctrl_ == b.control(); }
2102-
2103-
// Dereferences the iterator without ABSL Hardening iterator invalidation
2104-
// checks.
2105-
reference unchecked_deref() const { return PolicyTraits::element(slot_); }
21062108
};
21072109

21082110
class const_iterator {
@@ -2143,14 +2145,13 @@ class raw_hash_set {
21432145
const GenerationType* gen)
21442146
: inner_(const_cast<ctrl_t*>(ctrl), const_cast<slot_type*>(slot), gen) {
21452147
}
2148+
bool unchecked_equals(const const_iterator& b) const {
2149+
return inner_.unchecked_equals(b.inner_);
2150+
}
21462151
ctrl_t* control() const { return inner_.control(); }
21472152
slot_type* slot() const { return inner_.slot(); }
21482153

21492154
iterator inner_;
2150-
2151-
bool unchecked_equals(const const_iterator& b) {
2152-
return inner_.unchecked_equals(b.inner_);
2153-
}
21542155
};
21552156

21562157
using node_type = node_handle<Policy, hash_policy_traits<Policy>, Alloc>;

0 commit comments

Comments
 (0)