Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp

Issue 2290543002: Avoid redundant hash calculations in CustomElementUpgradeSorter (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp
index 808bb32341f405895a89f3db763913a2346ca8e8..0067f1fdb48b105823681070040194be98d5f5b6 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.cpp
@@ -31,15 +31,16 @@ CustomElementUpgradeSorter::AddResult CustomElementUpgradeSorter::addToParentChi
Node* parent,
Node* child)
{
- ParentChildMap::iterator it = m_parentChildMap->find(parent);
- if (it != m_parentChildMap->end()) {
- it->value.add(child);
+ ParentChildMap::AddResult result = m_parentChildMap->add(parent, nullptr);
+ if (!result.isNewEntry) {
+ result.storedValue->value->add(child);
// The entry for the parent exists; so must its parents.
return kParentAlreadyExistsInMap;
}
- ParentChildMap::AddResult result =
- m_parentChildMap->add(parent, HeapHashSet<Member<Node>>());
- result.storedValue->value.add(child);
+
+ ChildSet* childSet = new ChildSet();
+ childSet->add(child);
+ result.storedValue->value = childSet;
return kParentAddedToMap;
}
@@ -86,10 +87,10 @@ void CustomElementUpgradeSorter::sorted(
if (childrenIterator == m_parentChildMap->end())
return;
- ChildSet& children = childrenIterator->value;
+ ChildSet* children = childrenIterator->value.get();
- if (children.size() == 1) {
- visit(result, children, children.begin());
+ if (children->size() == 1) {
+ visit(result, *children, children->begin());
return;
}
@@ -99,19 +100,19 @@ void CustomElementUpgradeSorter::sorted(
? toElement(parent)->authorShadowRoot()
: nullptr;
if (shadowRoot)
- visit(result, children, children.find(shadowRoot));
+ visit(result, *children, children->find(shadowRoot));
for (Element* e = ElementTraversal::firstChild(*parent);
- e && children.size() > 1;
+ e && children->size() > 1;
e = ElementTraversal::nextSibling(*e)) {
- visit(result, children, children.find(e));
+ visit(result, *children, children->find(e));
}
- if (children.size() == 1)
- visit(result, children, children.begin());
+ if (children->size() == 1)
+ visit(result, *children, children->begin());
- DCHECK(children.isEmpty());
+ DCHECK(children->isEmpty());
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElementUpgradeSorter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698