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

Unified Diff: third_party/WebKit/Source/wtf/HashMap.h

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/HashCountedSet.h ('k') | third_party/WebKit/Source/wtf/HashMapTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/HashMap.h
diff --git a/third_party/WebKit/Source/wtf/HashMap.h b/third_party/WebKit/Source/wtf/HashMap.h
index a70d000088643ffcb787d4863458173c39111fdc..e7b492c204d749e1818fb3abeb4298988835def7 100644
--- a/third_party/WebKit/Source/wtf/HashMap.h
+++ b/third_party/WebKit/Source/wtf/HashMap.h
@@ -149,6 +149,8 @@ class HashMap {
// was actually added
template <typename IncomingKeyType, typename IncomingMappedType>
AddResult add(IncomingKeyType&&, IncomingMappedType&&);
+ template <typename IncomingKeyType, typename IncomingMappedType>
+ AddResult insert(IncomingKeyType&&, IncomingMappedType&&);
void remove(KeyPeekInType);
void remove(iterator);
@@ -183,6 +185,10 @@ class HashMap {
typename IncomingKeyType,
typename IncomingMappedType>
AddResult add(IncomingKeyType&&, IncomingMappedType&&);
haraken 2017/02/03 03:47:13 Shall we add a TODO that add() is deprecated?
+ template <typename HashTranslator,
+ typename IncomingKeyType,
+ typename IncomingMappedType>
+ AddResult insert(IncomingKeyType&&, IncomingMappedType&&);
static bool isValidKey(KeyPeekInType);
@@ -351,7 +357,7 @@ HashMap<T, U, V, W, X, Y>::HashMap(std::initializer_list<ValueType> elements) {
if (elements.size())
m_impl.reserveCapacityForSize(elements.size());
for (const ValueType& element : elements)
- add(element.key, element.value);
+ insert(element.key, element.value);
}
template <typename T,
@@ -575,6 +581,24 @@ template <typename T,
typename W,
typename X,
typename Y>
+template <typename HashTranslator,
+ typename IncomingKeyType,
+ typename IncomingMappedType>
+auto HashMap<T, U, V, W, X, Y>::insert(IncomingKeyType&& key,
+ IncomingMappedType&& mapped)
+ -> AddResult {
+ return m_impl.template addPassingHashCode<
+ HashMapTranslatorAdapter<ValueTraits, HashTranslator>>(
+ std::forward<IncomingKeyType>(key),
+ std::forward<IncomingMappedType>(mapped));
+}
+
+template <typename T,
+ typename U,
+ typename V,
+ typename W,
+ typename X,
+ typename Y>
template <typename IncomingKeyType, typename IncomingMappedType>
typename HashMap<T, U, V, W, X, Y>::AddResult HashMap<T, U, V, W, X, Y>::add(
IncomingKeyType&& key,
@@ -589,6 +613,20 @@ template <typename T,
typename W,
typename X,
typename Y>
+template <typename IncomingKeyType, typename IncomingMappedType>
+typename HashMap<T, U, V, W, X, Y>::AddResult HashMap<T, U, V, W, X, Y>::insert(
+ IncomingKeyType&& key,
+ IncomingMappedType&& mapped) {
+ return inlineAdd(std::forward<IncomingKeyType>(key),
+ std::forward<IncomingMappedType>(mapped));
+}
+
+template <typename T,
+ typename U,
+ typename V,
+ typename W,
+ typename X,
+ typename Y>
typename HashMap<T, U, V, W, X, Y>::MappedPeekType
HashMap<T, U, V, W, X, Y>::get(KeyPeekInType key) const {
ValueType* entry = const_cast<HashTableType&>(m_impl).lookup(key);
« no previous file with comments | « third_party/WebKit/Source/wtf/HashCountedSet.h ('k') | third_party/WebKit/Source/wtf/HashMapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698