aboutsummaryrefslogtreecommitdiff
path: root/absl/container/internal/raw_hash_set.cc
diff options
context:
space:
mode:
authorEvan Brown <ezb@google.com>2023-08-04 10:34:09 -0700
committerCopybara-Service <copybara-worker@google.com>2023-08-04 10:35:17 -0700
commit8f241e778c08cfb4213877b5022442a8d1921b58 (patch)
treef61de6bad1cbf5f6feb9ab96ea156bb44f8ea683 /absl/container/internal/raw_hash_set.cc
parent039d70f69b34b59d9696c655689316a94026fd0e (diff)
downloadabseil-8f241e778c08cfb4213877b5022442a8d1921b58.tar.gz
abseil-8f241e778c08cfb4213877b5022442a8d1921b58.tar.bz2
abseil-8f241e778c08cfb4213877b5022442a8d1921b58.zip
Store infoz on the heap instead of inline and store it only when we are sampling the current allocation.
PiperOrigin-RevId: 553847957 Change-Id: Idd131d0362bf36bd22d9bd20df54bd9ae50f0e28
Diffstat (limited to 'absl/container/internal/raw_hash_set.cc')
-rw-r--r--absl/container/internal/raw_hash_set.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc
index 2ff95b61..df64e7e8 100644
--- a/absl/container/internal/raw_hash_set.cc
+++ b/absl/container/internal/raw_hash_set.cc
@@ -220,7 +220,7 @@ 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);
+ c.decrement_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();
@@ -247,14 +247,15 @@ void ClearBackingArray(CommonFields& c, const PolicyFunctions& policy,
ResetCtrl(c, policy.slot_size);
c.infoz().RecordStorageChanged(0, c.capacity());
} else {
+ // We need to record infoz before calling dealloc, which will unregister
+ // infoz.
+ c.infoz().RecordClearedReservation();
+ c.infoz().RecordStorageChanged(0, 0);
(*policy.dealloc)(c, policy);
c.set_control(EmptyGroup());
c.set_generation_ptr(EmptyGeneration());
c.set_slots(nullptr);
c.set_capacity(0);
- c.infoz().RecordClearedReservation();
- assert(c.size() == 0);
- c.infoz().RecordStorageChanged(0, 0);
}
}