Skip to content
Permalink
Browse files
Micro-optimize the way we hand NodeLists to JSC.
<https://webkit.org/b/131932>

Use HashMap::fastAdd() when returning cached node lists and collections.
10.9% progression on Bindings/get-elements-by-tag-name.html

Reviewed by Antti Koivisto.

* dom/NodeRareData.h:
(WebCore::NodeListsNodeData::addCacheWithAtomicName):
(WebCore::NodeListsNodeData::addCacheWithName):
(WebCore::NodeListsNodeData::addCacheWithQualifiedName):
(WebCore::NodeListsNodeData::addCachedCollection):


Canonical link: https://commits.webkit.org/150009@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Apr 21, 2014
1 parent ac48074 commit b16fcbbf62d374e09db30280f96b9b0a1c32df19
Showing with 21 additions and 5 deletions.
  1. +16 −0 Source/WebCore/ChangeLog
  2. +5 −5 Source/WebCore/dom/NodeRareData.h
@@ -1,3 +1,19 @@
2014-04-21 Andreas Kling <akling@apple.com>

Micro-optimize the way we hand NodeLists to JSC.
<https://webkit.org/b/131932>

Use HashMap::fastAdd() when returning cached node lists and collections.
10.9% progression on Bindings/get-elements-by-tag-name.html

Reviewed by Antti Koivisto.

* dom/NodeRareData.h:
(WebCore::NodeListsNodeData::addCacheWithAtomicName):
(WebCore::NodeListsNodeData::addCacheWithName):
(WebCore::NodeListsNodeData::addCacheWithQualifiedName):
(WebCore::NodeListsNodeData::addCachedCollection):

2014-04-21 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r167584.
@@ -120,7 +120,7 @@ class NodeListsNodeData {
template<typename T, typename ContainerType>
PassRef<T> addCacheWithAtomicName(ContainerType& container, const AtomicString& name)
{
NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey<T>(name), nullptr);
NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.fastAdd(namedNodeListKey<T>(name), nullptr);
if (!result.isNewEntry)
return static_cast<T&>(*result.iterator->value);

@@ -132,7 +132,7 @@ class NodeListsNodeData {
template<typename T>
PassRef<T> addCacheWithName(ContainerNode& node, const String& name)
{
NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey<T>(name), nullptr);
NodeListNameCacheMap::AddResult result = m_nameCaches.fastAdd(namedNodeListKey<T>(name), nullptr);
if (!result.isNewEntry)
return static_cast<T&>(*result.iterator->value);

@@ -144,7 +144,7 @@ class NodeListsNodeData {
PassRef<TagNodeList> addCacheWithQualifiedName(ContainerNode& node, const AtomicString& namespaceURI, const AtomicString& localName)
{
QualifiedName name(nullAtom, localName, namespaceURI);
TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.add(name, nullptr);
TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.fastAdd(name, nullptr);
if (!result.isNewEntry)
return *result.iterator->value;

@@ -156,7 +156,7 @@ class NodeListsNodeData {
template<typename T, typename ContainerType>
PassRef<T> addCachedCollection(ContainerType& container, CollectionType collectionType, const AtomicString& name)
{
CollectionCacheMap::AddResult result = m_cachedCollections.add(namedCollectionKey(collectionType, name), nullptr);
CollectionCacheMap::AddResult result = m_cachedCollections.fastAdd(namedCollectionKey(collectionType, name), nullptr);
if (!result.isNewEntry)
return static_cast<T&>(*result.iterator->value);

@@ -168,7 +168,7 @@ class NodeListsNodeData {
template<typename T, typename ContainerType>
PassRef<T> addCachedCollection(ContainerType& container, CollectionType collectionType)
{
CollectionCacheMap::AddResult result = m_cachedCollections.add(namedCollectionKey(collectionType, starAtom), nullptr);
CollectionCacheMap::AddResult result = m_cachedCollections.fastAdd(namedCollectionKey(collectionType, starAtom), nullptr);
if (!result.isNewEntry)
return static_cast<T&>(*result.iterator->value);

0 comments on commit b16fcbb

Please sign in to comment.