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

Side by Side Diff: third_party/WebKit/Source/core/dom/WeakIdentifierMap.h

Issue 2673543003: Migrate WTF::HashMap::remove() to ::erase() (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WeakIdentifierMap_h 5 #ifndef WeakIdentifierMap_h
6 #define WeakIdentifierMap_h 6 #define WeakIdentifierMap_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 void put(T* object, IdentifierType identifier) { 80 void put(T* object, IdentifierType identifier) {
81 DCHECK(object && !this->m_objectToIdentifier.contains(object)); 81 DCHECK(object && !this->m_objectToIdentifier.contains(object));
82 this->m_objectToIdentifier.set(object, identifier); 82 this->m_objectToIdentifier.set(object, identifier);
83 this->m_identifierToObject.set(identifier, object); 83 this->m_identifierToObject.set(identifier, object);
84 } 84 }
85 85
86 void objectDestroyed(T* object) { 86 void objectDestroyed(T* object) {
87 IdentifierType identifier = this->m_objectToIdentifier.take(object); 87 IdentifierType identifier = this->m_objectToIdentifier.take(object);
88 if (!WTF::isHashTraitsEmptyValue<HashTraits<IdentifierType>>(identifier)) 88 if (!WTF::isHashTraitsEmptyValue<HashTraits<IdentifierType>>(identifier))
89 this->m_identifierToObject.remove(identifier); 89 this->m_identifierToObject.erase(identifier);
90 } 90 }
91 }; 91 };
92 92
93 #define DECLARE_WEAK_IDENTIFIER_MAP(T, ...) \ 93 #define DECLARE_WEAK_IDENTIFIER_MAP(T, ...) \
94 template <> \ 94 template <> \
95 WeakIdentifierMap<T, ##__VA_ARGS__>& \ 95 WeakIdentifierMap<T, ##__VA_ARGS__>& \
96 WeakIdentifierMap<T, ##__VA_ARGS__>::instance(); \ 96 WeakIdentifierMap<T, ##__VA_ARGS__>::instance(); \
97 extern template class WeakIdentifierMap<T, ##__VA_ARGS__>; 97 extern template class WeakIdentifierMap<T, ##__VA_ARGS__>;
98 98
99 #define DEFINE_WEAK_IDENTIFIER_MAP(T, ...) \ 99 #define DEFINE_WEAK_IDENTIFIER_MAP(T, ...) \
100 template class WeakIdentifierMap<T, ##__VA_ARGS__>; \ 100 template class WeakIdentifierMap<T, ##__VA_ARGS__>; \
101 template <> \ 101 template <> \
102 WeakIdentifierMap<T, ##__VA_ARGS__>& \ 102 WeakIdentifierMap<T, ##__VA_ARGS__>& \
103 WeakIdentifierMap<T, ##__VA_ARGS__>::instance() { \ 103 WeakIdentifierMap<T, ##__VA_ARGS__>::instance() { \
104 using RefType = WeakIdentifierMap<T, ##__VA_ARGS__>; \ 104 using RefType = WeakIdentifierMap<T, ##__VA_ARGS__>; \
105 DEFINE_STATIC_LOCAL(RefType, mapInstance, \ 105 DEFINE_STATIC_LOCAL(RefType, mapInstance, \
106 (new WeakIdentifierMap<T, ##__VA_ARGS__>())); \ 106 (new WeakIdentifierMap<T, ##__VA_ARGS__>())); \
107 return mapInstance; \ 107 return mapInstance; \
108 } 108 }
109 109
110 } // namespace blink 110 } // namespace blink
111 111
112 #endif // WeakIdentifierMap_h 112 #endif // WeakIdentifierMap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698