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

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

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs 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 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 08095da08a43ba9b830111467fe868bc1888de74..eb58eeafd520045a7593df44935fbadad0d8c4e1 100644
--- a/third_party/WebKit/Source/wtf/HashMap.h
+++ b/third_party/WebKit/Source/wtf/HashMap.h
@@ -147,8 +147,12 @@ class HashMap {
// does nothing if key is already present return value is a pair of the
// iterator to the key location, and a boolean that's true if a new value
// was actually added
+ // TODO(pilgrim) remove deprecated add() method, use insert() instead
+ // https://crbug.com/662431
template <typename IncomingKeyType, typename IncomingMappedType>
AddResult add(IncomingKeyType&&, IncomingMappedType&&);
+ template <typename IncomingKeyType, typename IncomingMappedType>
+ AddResult insert(IncomingKeyType&&, IncomingMappedType&&);
// TODO(pilgrim) remove remove() method once all references migrated to
// erase()
@@ -183,10 +187,16 @@ class HashMap {
// static unsigned hash(const T&);
// static bool equal(const ValueType&, const T&);
// static translate(ValueType&, const T&, unsigned hashCode);
+ // TODO(pilgrim) remove deprecated add() method, use insert() instead
+ // https://crbug.com/662431
template <typename HashTranslator,
typename IncomingKeyType,
typename IncomingMappedType>
AddResult add(IncomingKeyType&&, IncomingMappedType&&);
+ template <typename HashTranslator,
+ typename IncomingKeyType,
+ typename IncomingMappedType>
+ AddResult insert(IncomingKeyType&&, IncomingMappedType&&);
static bool isValidKey(KeyPeekInType);
@@ -355,7 +365,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,
@@ -579,6 +589,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,
@@ -593,6 +621,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