Bug 1202526 (part 8) - Use PLDHashTable::RemoveEntry() in the cycle collector. r=mccr8.

This avoids repeating the hash table search in order to remove a CC graph
entry, which is good because it's a common operation.
This commit is contained in:
Nicholas Nethercote 2015-09-07 21:15:32 -07:00
Родитель 957b39e8ff
Коммит ffb1fefc9f
1 изменённых файлов: 16 добавлений и 7 удалений

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

@ -868,9 +868,10 @@ public:
}
#endif
PtrToNodeEntry* FindNodeEntry(void* aPtr);
PtrInfo* FindNode(void* aPtr);
PtrToNodeEntry* AddNodeToMap(void* aPtr);
void RemoveNodeFromMap(void* aPtr);
void RemoveNodeFromMap(PtrToNodeEntry* aPtr);
uint32_t MapCount() const
{
@ -894,11 +895,17 @@ public:
}
};
PtrToNodeEntry*
CCGraph::FindNodeEntry(void* aPtr)
{
return
static_cast<PtrToNodeEntry*>(PL_DHashTableSearch(&mPtrToNodeMap, aPtr));
}
PtrInfo*
CCGraph::FindNode(void* aPtr)
{
PtrToNodeEntry* e =
static_cast<PtrToNodeEntry*>(PL_DHashTableSearch(&mPtrToNodeMap, aPtr));
PtrToNodeEntry* e = FindNodeEntry(aPtr);
return e ? e->mNode : nullptr;
}
@ -921,9 +928,9 @@ CCGraph::AddNodeToMap(void* aPtr)
}
void
CCGraph::RemoveNodeFromMap(void* aPtr)
CCGraph::RemoveNodeFromMap(PtrToNodeEntry* aEntry)
{
PL_DHashTableRemove(&mPtrToNodeMap, aPtr);
mPtrToNodeMap.RemoveEntry(aEntry);
}
@ -3838,8 +3845,10 @@ nsCycleCollector::RemoveObjectFromGraph(void* aObj)
return;
}
if (PtrInfo* pinfo = mGraph.FindNode(aObj)) {
mGraph.RemoveNodeFromMap(aObj);
PtrToNodeEntry* e = mGraph.FindNodeEntry(aObj);
PtrInfo* pinfo = e ? e->mNode : nullptr;
if (pinfo) {
mGraph.RemoveNodeFromMap(e);
pinfo->mPointer = nullptr;
pinfo->mParticipant = nullptr;