mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 659539 Part 5: Speed up nsINodeInfo::GetDocument by caching the nodeinfo managers mDocument pointer. r=bz
This commit is contained in:
parent
9d5d1f3219
commit
3ff01744c1
@ -309,7 +309,7 @@ public:
|
||||
*/
|
||||
nsIDocument* GetDocument() const
|
||||
{
|
||||
return mOwnerManager->GetDocument();
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -359,6 +359,8 @@ protected:
|
||||
// nsNodeInfoManager needs to pass mInner to the hash table.
|
||||
friend class nsNodeInfoManager;
|
||||
|
||||
nsIDocument* mDocument; // Weak. Cache of mOwnerManager->mDocument
|
||||
|
||||
nsNodeInfoInner mInner;
|
||||
|
||||
nsCOMPtr<nsIAtom> mIDAttributeAtom;
|
||||
|
@ -120,6 +120,8 @@ nsNodeInfo::nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
NS_ADDREF(mOwnerManager = aOwnerManager);
|
||||
NS_IF_ADDREF(mInner.mExtraName = aExtraName);
|
||||
|
||||
mDocument = aOwnerManager->GetDocument();
|
||||
|
||||
// Now compute our cached members.
|
||||
|
||||
// Qualified name. If we have no prefix, use ToString on
|
||||
|
@ -194,6 +194,14 @@ nsNodeInfoManager::Init(nsIDocument *aDocument)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
PRIntn
|
||||
nsNodeInfoManager::DropNodeInfoDocument(PLHashEntry *he, PRIntn hashIndex, void *arg)
|
||||
{
|
||||
static_cast<nsINodeInfo*>(he->value)->mDocument = nsnull;
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
nsNodeInfoManager::DropDocumentReference()
|
||||
{
|
||||
@ -201,6 +209,8 @@ nsNodeInfoManager::DropDocumentReference()
|
||||
mBindingManager->DropDocumentReference();
|
||||
}
|
||||
|
||||
PL_HashTableEnumerateEntries(mNodeInfoHash, DropNodeInfoDocument, nsnull);
|
||||
|
||||
mDocument = nsnull;
|
||||
}
|
||||
|
||||
|
@ -153,6 +153,8 @@ protected:
|
||||
private:
|
||||
static PRIntn NodeInfoInnerKeyCompare(const void *key1, const void *key2);
|
||||
static PLHashNumber GetNodeInfoInnerHashValue(const void *key);
|
||||
static PRIntn DropNodeInfoDocument(PLHashEntry *he, PRIntn hashIndex,
|
||||
void *arg);
|
||||
|
||||
PLHashTable *mNodeInfoHash;
|
||||
nsIDocument *mDocument; // WEAK
|
||||
|
Loading…
Reference in New Issue
Block a user