Bug 1692403 - Don't shrink hashtable in EntryHandle destructor. r=xpcom-reviewers,nika

Differential Revision: https://phabricator.services.mozilla.com/D108171
This commit is contained in:
Simon Giesecke 2021-03-25 08:34:32 +00:00
Родитель 4f0b94ee34
Коммит 1cfa7f12c5
2 изменённых файлов: 15 добавлений и 7 удалений

Просмотреть файл

@ -697,20 +697,15 @@ PLDHashTable::EntryHandle::EntryHandle(EntryHandle&& aOther) noexcept
mKeyHash(aOther.mKeyHash),
mSlot(aOther.mSlot) {}
#ifdef MOZ_HASH_TABLE_CHECKS_ENABLED
PLDHashTable::EntryHandle::~EntryHandle() {
if (!mTable) {
return;
}
// If our slot is empty when this `EntryHandle` is destroyed, we may want to
// resize our table, as we just removed an entry.
if (!HasEntry()) {
mTable->ShrinkIfAppropriate();
}
#ifdef MOZ_HASH_TABLE_CHECKS_ENABLED
mTable->mChecker.EndWriteOp();
#endif
}
#endif
void PLDHashTable::EntryHandle::Remove() {
MOZ_ASSERT(HasEntry());

Просмотреть файл

@ -532,7 +532,9 @@ class PLDHashTable {
class EntryHandle {
public:
EntryHandle(EntryHandle&& aOther) noexcept;
#ifdef MOZ_HASH_TABLE_CHECKS_ENABLED
~EntryHandle();
#endif
EntryHandle(const EntryHandle&) = delete;
EntryHandle& operator=(const EntryHandle&) = delete;
@ -568,8 +570,19 @@ class PLDHashTable {
return Entry();
}
/** Removes the entry. Note that the table won't shrink on destruction of
* the EntryHandle.
*
* \pre HasEntry()
* \post !HasEntry()
*/
void Remove();
/** Removes the entry, if it exists. Note that the table won't shrink on
* destruction of the EntryHandle.
*
* \post !HasEntry()
*/
void OrRemove();
private: