mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1202526 (part 1) - Add PLDHashTable::RemoveEntry(). r=froydnj.
This patch also consolidates the shrink handling so it's now entirely within ShrinkIfAppropriate().
This commit is contained in:
parent
fa9656d2f2
commit
980d9f7a73
@ -662,18 +662,22 @@ PLDHashTable::Remove(const void* aKey)
|
||||
ComputeKeyHash(aKey))
|
||||
: nullptr;
|
||||
if (entry) {
|
||||
// Clear this entry and mark it as "removed".
|
||||
RawRemove(entry);
|
||||
|
||||
// Shrink if alpha is <= .25 and the table isn't too small already.
|
||||
uint32_t capacity = Capacity();
|
||||
if (capacity > kMinCapacity &&
|
||||
mEntryCount <= MinLoad(capacity)) {
|
||||
(void) ChangeTable(-1);
|
||||
}
|
||||
ShrinkIfAppropriate();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PLDHashTable::RemoveEntry(PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
AutoWriteOp op(mChecker);
|
||||
#endif
|
||||
|
||||
RawRemove(aEntry);
|
||||
ShrinkIfAppropriate();
|
||||
}
|
||||
|
||||
PLDHashEntryHdr* PL_DHASH_FASTCALL
|
||||
PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey)
|
||||
{
|
||||
@ -709,7 +713,7 @@ PLDHashTable::RawRemove(PLDHashEntryHdr* aEntry)
|
||||
|
||||
MOZ_ASSERT(mEntryStore.Get());
|
||||
|
||||
NS_ASSERTION(EntryIsLive(aEntry), "EntryIsLive(aEntry)");
|
||||
MOZ_ASSERT(EntryIsLive(aEntry), "EntryIsLive(aEntry)");
|
||||
|
||||
// Load keyHash first in case clearEntry() goofs it.
|
||||
PLDHashNumber keyHash = aEntry->mKeyHash;
|
||||
|
@ -350,12 +350,23 @@ public:
|
||||
// table.Remove(key);
|
||||
//
|
||||
// If |key|'s entry is found, it is cleared (via table->mOps->clearEntry).
|
||||
// The table's capacity may be reduced afterwards.
|
||||
void Remove(const void* aKey);
|
||||
|
||||
// To remove an entry found by a prior search, call:
|
||||
//
|
||||
// table.RemoveEntry(entry);
|
||||
//
|
||||
// The entry, which must be present and in use, is cleared (via
|
||||
// table->mOps->clearEntry). The table's capacity may be reduced afterwards.
|
||||
void RemoveEntry(PLDHashEntryHdr* aEntry);
|
||||
|
||||
// Remove an entry already accessed via Search() or Add().
|
||||
//
|
||||
// NB: this is a "raw" or low-level method. It does not shrink the table if
|
||||
// it is underloaded. Don't use it unless you know what you are doing.
|
||||
// it is underloaded. Don't use it unless necessary and you know what you are
|
||||
// doing, and if so, please explain in a comment why it is necessary instead
|
||||
// of RemoveEntry().
|
||||
void RawRemove(PLDHashEntryHdr* aEntry);
|
||||
|
||||
// This function is equivalent to
|
||||
|
Loading…
Reference in New Issue
Block a user