зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
4f0b94ee34
Коммит
1cfa7f12c5
|
@ -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:
|
||||
|
|
Загрузка…
Ссылка в новой задаче