Chromium Code Reviews| 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); |