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) |