summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-25 09:14:03 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:52 -0500
commit3c70b297c7be12b7d7e120de04a38f40b600928b (patch)
treefb5b7a509abe61a05bf6f3f88371271be4e5ccaa /dom/base
parent0cea94242a555b7a8a2d956412da809a514814f7 (diff)
downloadUXP-3c70b297c7be12b7d7e120de04a38f40b600928b.tar
UXP-3c70b297c7be12b7d7e120de04a38f40b600928b.tar.gz
UXP-3c70b297c7be12b7d7e120de04a38f40b600928b.tar.lz
UXP-3c70b297c7be12b7d7e120de04a38f40b600928b.tar.xz
UXP-3c70b297c7be12b7d7e120de04a38f40b600928b.zip
Bug 1430951 - Avoid element name atomizing to improve performance of LookupCustomElementDefinition
Since we are dealing with the element (nodeInfo->LocalName() and NameAtom() are the same value), we could use nodeInfo->NameAtom() instead. Tag UXP Issue #1344
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/CustomElementRegistry.cpp5
-rw-r--r--dom/base/CustomElementRegistry.h2
-rw-r--r--dom/base/nsContentUtils.cpp8
-rw-r--r--dom/base/nsContentUtils.h2
-rw-r--r--dom/base/nsNodeUtils.cpp4
5 files changed, 12 insertions, 9 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index 47601aabb..99452df65 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -243,12 +243,11 @@ CustomElementRegistry::~CustomElementRegistry()
}
CustomElementDefinition*
-CustomElementRegistry::LookupCustomElementDefinition(const nsAString& aLocalName,
+CustomElementRegistry::LookupCustomElementDefinition(nsIAtom* aNameAtom,
nsIAtom* aTypeAtom) const
{
- nsCOMPtr<nsIAtom> localNameAtom = NS_Atomize(aLocalName);
CustomElementDefinition* data = mCustomDefinitions.GetWeak(aTypeAtom);
- if (data && data->mLocalName == localNameAtom) {
+ if (data && data->mLocalName == aNameAtom) {
return data;
}
diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h
index 01c32a595..c416e5043 100644
--- a/dom/base/CustomElementRegistry.h
+++ b/dom/base/CustomElementRegistry.h
@@ -412,7 +412,7 @@ public:
* https://html.spec.whatwg.org/#look-up-a-custom-element-definition
*/
CustomElementDefinition* LookupCustomElementDefinition(
- const nsAString& aLocalName, nsIAtom* aTypeAtom) const;
+ nsIAtom* aNameAtom, nsIAtom* aTypeAtom) const;
CustomElementDefinition* LookupCustomElementDefinition(
JSContext* aCx, JSObject *aConstructor) const;
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index 402dfd1c5..b6cbbbace 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -9536,9 +9536,11 @@ nsContentUtils::TryToUpgradeElement(Element* aElement)
NodeInfo* nodeInfo = aElement->NodeInfo();
RefPtr<nsIAtom> typeAtom =
aElement->GetCustomElementData()->GetCustomElementType();
+
+ MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName()));
CustomElementDefinition* definition =
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
- nodeInfo->LocalName(),
+ nodeInfo->NameAtom(),
nodeInfo->NamespaceID(),
typeAtom);
if (definition) {
@@ -9553,7 +9555,7 @@ nsContentUtils::TryToUpgradeElement(Element* aElement)
/* static */ CustomElementDefinition*
nsContentUtils::LookupCustomElementDefinition(nsIDocument* aDoc,
- const nsAString& aLocalName,
+ nsIAtom* aNameAtom,
uint32_t aNameSpaceID,
nsIAtom* aTypeAtom)
{
@@ -9577,7 +9579,7 @@ nsContentUtils::LookupCustomElementDefinition(nsIDocument* aDoc,
return nullptr;
}
- return registry->LookupCustomElementDefinition(aLocalName, aTypeAtom);
+ return registry->LookupCustomElementDefinition(aNameAtom, aTypeAtom);
}
/* static */ void
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index 4200a0621..bf6a59dcd 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2712,7 +2712,7 @@ public:
*/
static mozilla::dom::CustomElementDefinition*
LookupCustomElementDefinition(nsIDocument* aDoc,
- const nsAString& aLocalName,
+ nsIAtom* aNameAtom,
uint32_t aNameSpaceID,
nsIAtom* aTypeAtom);
diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp
index f79da6652..384e56cde 100644
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -497,9 +497,11 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
if (data || !extension.IsEmpty()) {
RefPtr<nsIAtom> typeAtom = extension.IsEmpty() ? tagAtom : NS_Atomize(extension);
cloneElem->SetCustomElementData(new CustomElementData(typeAtom));
+
+ MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName()));
CustomElementDefinition* definition =
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
- nodeInfo->LocalName(),
+ nodeInfo->NameAtom(),
nodeInfo->NamespaceID(),
typeAtom);
if (definition) {