diff --git a/xpcom/ds/PLDHashTable.cpp b/xpcom/ds/PLDHashTable.cpp index 6152e90003c0..f41d3fc451d1 100644 --- a/xpcom/ds/PLDHashTable.cpp +++ b/xpcom/ds/PLDHashTable.cpp @@ -366,11 +366,9 @@ PLDHashTable::SearchTable(const void* aKey, PLDHashNumber aKeyHash) PLDHashEntryHdr* firstRemoved = nullptr; for (;;) { - if (Reason == ForAdd) { + if (Reason == ForAdd && !firstRemoved) { if (MOZ_UNLIKELY(EntryIsRemoved(entry))) { - if (!firstRemoved) { - firstRemoved = entry; - } + firstRemoved = entry; } else { entry->mKeyHash |= kCollisionFlag; }