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

Side by Side Diff: Source/core/dom/DocumentOrderedMap.h

Issue 123333003: Use a pointer type for values in DocumentOrderedMap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/dom/DocumentOrderedMap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Element* getElementByMapName(StringImpl*, const TreeScope*) const; 55 Element* getElementByMapName(StringImpl*, const TreeScope*) const;
56 Element* getElementByLowercasedMapName(StringImpl*, const TreeScope*) const; 56 Element* getElementByLowercasedMapName(StringImpl*, const TreeScope*) const;
57 Element* getElementByLabelForAttribute(StringImpl*, const TreeScope*) const; 57 Element* getElementByLabelForAttribute(StringImpl*, const TreeScope*) const;
58 58
59 void checkConsistency() const; 59 void checkConsistency() const;
60 60
61 private: 61 private:
62 template<bool keyMatches(StringImpl*, Element*)> Element* get(StringImpl*, c onst TreeScope*) const; 62 template<bool keyMatches(StringImpl*, Element*)> Element* get(StringImpl*, c onst TreeScope*) const;
63 63
64 struct MapEntry { 64 struct MapEntry {
65 MapEntry()
66 : element(0)
67 , count(0)
68 { }
69
70 explicit MapEntry(Element* firstElement) 65 explicit MapEntry(Element* firstElement)
71 : element(firstElement) 66 : element(firstElement)
72 , count(1) 67 , count(1)
73 { } 68 { }
74 69
75 Element* element; 70 Element* element;
76 unsigned count; 71 unsigned count;
77 Vector<Element*> orderedList; 72 Vector<Element*> orderedList;
78 }; 73 };
79 74
80 typedef HashMap<StringImpl*, MapEntry> Map; 75 typedef HashMap<StringImpl*, OwnPtr<MapEntry> > Map;
81 76
82 mutable Map m_map; 77 mutable Map m_map;
83 }; 78 };
84 79
85 inline bool DocumentOrderedMap::contains(StringImpl* id) const 80 inline bool DocumentOrderedMap::contains(StringImpl* id) const
86 { 81 {
87 return m_map.contains(id); 82 return m_map.contains(id);
88 } 83 }
89 84
90 inline bool DocumentOrderedMap::containsMultiple(StringImpl* id) const 85 inline bool DocumentOrderedMap::containsMultiple(StringImpl* id) const
91 { 86 {
92 Map::const_iterator it = m_map.find(id); 87 Map::const_iterator it = m_map.find(id);
93 return it != m_map.end() && it->value.count > 1; 88 return it != m_map.end() && it->value->count > 1;
94 } 89 }
95 90
96 } // namespace WebCore 91 } // namespace WebCore
97 92
98 #endif // DocumentOrderedMap_h 93 #endif // DocumentOrderedMap_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/DocumentOrderedMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698