Skip to content

Commit 1cfa7f1

Browse files
committed
Bug 1692403 - Don't shrink hashtable in EntryHandle destructor. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D108171
1 parent 4f0b94e commit 1cfa7f1

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

xpcom/ds/PLDHashTable.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,20 +697,15 @@ PLDHashTable::EntryHandle::EntryHandle(EntryHandle&& aOther) noexcept
697697
mKeyHash(aOther.mKeyHash),
698698
mSlot(aOther.mSlot) {}
699699

700+
#ifdef MOZ_HASH_TABLE_CHECKS_ENABLED
700701
PLDHashTable::EntryHandle::~EntryHandle() {
701702
if (!mTable) {
702703
return;
703704
}
704705

705-
// If our slot is empty when this `EntryHandle` is destroyed, we may want to
706-
// resize our table, as we just removed an entry.
707-
if (!HasEntry()) {
708-
mTable->ShrinkIfAppropriate();
709-
}
710-
#ifdef MOZ_HASH_TABLE_CHECKS_ENABLED
711706
mTable->mChecker.EndWriteOp();
712-
#endif
713707
}
708+
#endif
714709

715710
void PLDHashTable::EntryHandle::Remove() {
716711
MOZ_ASSERT(HasEntry());

xpcom/ds/PLDHashTable.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ class PLDHashTable {
532532
class EntryHandle {
533533
public:
534534
EntryHandle(EntryHandle&& aOther) noexcept;
535+
#ifdef MOZ_HASH_TABLE_CHECKS_ENABLED
535536
~EntryHandle();
537+
#endif
536538

537539
EntryHandle(const EntryHandle&) = delete;
538540
EntryHandle& operator=(const EntryHandle&) = delete;
@@ -568,8 +570,19 @@ class PLDHashTable {
568570
return Entry();
569571
}
570572

573+
/** Removes the entry. Note that the table won't shrink on destruction of
574+
* the EntryHandle.
575+
*
576+
* \pre HasEntry()
577+
* \post !HasEntry()
578+
*/
571579
void Remove();
572580

581+
/** Removes the entry, if it exists. Note that the table won't shrink on
582+
* destruction of the EntryHandle.
583+
*
584+
* \post !HasEntry()
585+
*/
573586
void OrRemove();
574587

575588
private:

0 commit comments

Comments
 (0)