| Index: Source/core/dom/DocumentOrderedMap.h
|
| diff --git a/Source/core/dom/DocumentOrderedMap.h b/Source/core/dom/DocumentOrderedMap.h
|
| index b6fc8e07e0df1e0111506225fd0bc5c4bd1e0cc8..46e33768319be28e2c8d61c5faeef1817df2e06d 100644
|
| --- a/Source/core/dom/DocumentOrderedMap.h
|
| +++ b/Source/core/dom/DocumentOrderedMap.h
|
| @@ -1,4 +1,5 @@
|
| /*
|
| + *
|
| * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| @@ -33,6 +34,7 @@
|
|
|
| #include "wtf/HashCountedSet.h"
|
| #include "wtf/HashMap.h"
|
| +#include "wtf/Vector.h"
|
| #include "wtf/text/StringImpl.h"
|
|
|
| namespace WebCore {
|
| @@ -50,6 +52,7 @@ public:
|
| bool containsMultiple(StringImpl*) const;
|
| // concrete instantiations of the get<>() method template
|
| Element* getElementById(StringImpl*, const TreeScope*) const;
|
| + const Vector<Element*>* getAllElementsById(StringImpl*, const TreeScope*) const;
|
| Element* getElementByMapName(StringImpl*, const TreeScope*) const;
|
| Element* getElementByLowercasedMapName(StringImpl*, const TreeScope*) const;
|
| Element* getElementByLabelForAttribute(StringImpl*, const TreeScope*) const;
|
| @@ -59,23 +62,37 @@ public:
|
| private:
|
| template<bool keyMatches(StringImpl*, Element*)> Element* get(StringImpl*, const TreeScope*) const;
|
|
|
| - typedef HashMap<StringImpl*, Element*> Map;
|
| + struct MapEntry {
|
| + MapEntry()
|
| + : element(0)
|
| + , count(0)
|
| + { }
|
| +
|
| + explicit MapEntry(Element* firstElement)
|
| + : element(firstElement)
|
| + , count(1)
|
| + { }
|
| +
|
| + Element* element;
|
| + unsigned count;
|
| + Vector<Element*> orderedList;
|
| + };
|
| +
|
| + typedef HashMap<StringImpl*, MapEntry> Map;
|
| +
|
|
|
| - // We maintain the invariant that m_duplicateCounts is the count of all elements with a given key
|
| - // excluding the one referenced in m_map, if any. This means it one less than the total count
|
| - // when the first node with a given key is cached, otherwise the same as the total count.
|
| mutable Map m_map;
|
| - mutable HashCountedSet<StringImpl*> m_duplicateCounts;
|
| };
|
|
|
| inline bool DocumentOrderedMap::contains(StringImpl* id) const
|
| {
|
| - return m_map.contains(id) || m_duplicateCounts.contains(id);
|
| + return m_map.contains(id);
|
| }
|
|
|
| inline bool DocumentOrderedMap::containsMultiple(StringImpl* id) const
|
| {
|
| - return m_duplicateCounts.contains(id);
|
| + Map::const_iterator it = m_map.find(id);
|
| + return it != m_map.end() && it->value.count > 1;
|
| }
|
|
|
| } // namespace WebCore
|
|
|