Bug 1383756 - Avoid excessive AddRef()ing of atoms in nsNodeInfoManager::GetNodeInfo(); r=baku

We make the NodeInfoInner members raw pointers, and AddRef/Release
them manally in the constructor/destructor of NodeInfo, and in the
cases where NodeInfoInner objects are created for hashtable lookups,
no further refcounting is performed.
This commit is contained in:
Ehsan Akhgari 2017-07-24 23:29:08 +02:00 коммит произвёл J. Ryan Stinnett
Родитель a1cf839e41
Коммит e2a3a27c3f
2 изменённых файлов: 14 добавлений и 3 удалений

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

@ -36,6 +36,13 @@ using mozilla::dom::NodeInfo;
NodeInfo::~NodeInfo()
{
mOwnerManager->RemoveNodeInfo(this);
// We can't use NS_IF_RELEASE because mName is const.
if (mInner.mName) {
mInner.mName->Release();
}
NS_IF_RELEASE(mInner.mPrefix);
NS_IF_RELEASE(mInner.mExtraName);
}
NodeInfo::NodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
@ -47,6 +54,10 @@ NodeInfo::NodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
{
CheckValidNodeInfo(aNodeType, aName, aNamespaceID, aExtraName);
NS_IF_ADDREF(mInner.mName);
NS_IF_ADDREF(mInner.mPrefix);
NS_IF_ADDREF(mInner.mExtraName);
// Now compute our cached members.
// Qualified name. If we have no prefix, use ToString on

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

@ -265,12 +265,12 @@ protected:
{
}
const nsCOMPtr<nsIAtom> mName;
nsCOMPtr<nsIAtom> mPrefix;
nsIAtom* const MOZ_OWNING_REF mName;
nsIAtom* MOZ_OWNING_REF mPrefix;
int32_t mNamespaceID;
uint16_t mNodeType; // As defined by nsIDOMNode.nodeType
const nsAString* const mNameString;
nsCOMPtr<nsIAtom> mExtraName; // Only used by PIs and DocTypes
nsIAtom* MOZ_OWNING_REF mExtraName; // Only used by PIs and DocTypes
PLHashNumber mHash;
bool mHashInitialized;
};