We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ShouldRehashForBugDetection
1 parent f1b7d00 commit ca210f1Copy full SHA for ca210f1
absl/container/internal/raw_hash_set.cc
@@ -134,6 +134,9 @@ GenerationType* EmptyGeneration() {
134
bool CommonFieldsGenerationInfoEnabled::
135
should_rehash_for_bug_detection_on_insert(const ctrl_t* ctrl,
136
size_t capacity) const {
137
+ // As an optimization, we avoid calling ShouldRehashForBugDetection during the
138
+ // first two insertions. In these cases, we'll end up rehashing anyways.
139
+ if (capacity == 0 || (capacity == 1 && IsFull(ctrl[0]))) return false;
140
if (reserved_growth_ == kReservedGrowthJustRanOut) return true;
141
if (reserved_growth_ > 0) return false;
142
return ShouldRehashForBugDetection(ctrl, capacity);
0 commit comments