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

Unified Diff: Source/core/dom/NodeRareData.h

Issue 141743010: Use a StringImpl* instead of an AtomicString for NodeListAtomicNameCacheMap's key (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment Created 6 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/NodeRareData.h
diff --git a/Source/core/dom/NodeRareData.h b/Source/core/dom/NodeRareData.h
index 403a0b2cc7492bba5265d8653d530301231c13e1..49ce9d72ab698b1864514032e14954cbcb9a86bf 100644
--- a/Source/core/dom/NodeRareData.h
+++ b/Source/core/dom/NodeRareData.h
@@ -94,7 +94,16 @@ public:
static const bool safeToCompareToEmptyOrDeleted = DefaultHash<StringType>::Hash::safeToCompareToEmptyOrDeleted;
};
- typedef HashMap<std::pair<unsigned char, AtomicString>, LiveNodeListBase*, NodeListCacheMapEntryHash<AtomicString> > NodeListAtomicNameCacheMap;
+ struct NodeListAtomicCacheMapEntryHash {
+ static unsigned hash(const std::pair<unsigned char, StringImpl*>& entry)
+ {
+ return DefaultHash<StringImpl*>::Hash::hash(entry.second) + entry.first;
+ }
+ static bool equal(const std::pair<unsigned char, StringImpl*>& a, const std::pair<unsigned char, StringImpl*>& b) { return a == b; }
+ static const bool safeToCompareToEmptyOrDeleted = DefaultHash<StringImpl*>::Hash::safeToCompareToEmptyOrDeleted;
+ };
+
+ typedef HashMap<std::pair<unsigned char, StringImpl*>, LiveNodeListBase*, NodeListAtomicCacheMapEntryHash> NodeListAtomicNameCacheMap;
typedef HashMap<std::pair<unsigned char, String>, LiveNodeListBase*, NodeListCacheMapEntryHash<String> > NodeListNameCacheMap;
typedef HashMap<QualifiedName, TagCollection*> TagCollectionCacheNS;
@@ -228,9 +237,11 @@ private:
: m_childNodeList(0)
{ }
- std::pair<unsigned char, AtomicString> namedNodeListKey(CollectionType type, const AtomicString& name)
+ std::pair<unsigned char, StringImpl*> namedNodeListKey(CollectionType type, const AtomicString& name)
{
- return std::pair<unsigned char, AtomicString>(type, name);
+ // Holding the raw StringImpl is safe because |name| is retained by the NodeList and the NodeList
+ // is reponsible for removing itself from the cache on deletion.
+ return std::pair<unsigned char, StringImpl*>(type, name.impl());
}
std::pair<unsigned char, String> namedNodeListKey(CollectionType type, const String& name)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698