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

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

Issue 1798913002: WTF HashSet: Implement move semantics for values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 9 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/HashSetTest.cpp ('k') | third_party/WebKit/Source/wtf/text/AtomicString.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/HashTable.h
diff --git a/third_party/WebKit/Source/wtf/HashTable.h b/third_party/WebKit/Source/wtf/HashTable.h
index bc2068041f88a26dd93481c1ddca3559f059c576..373dbda75bb434f7c78da8374f61bc68e46cc688 100644
--- a/third_party/WebKit/Source/wtf/HashTable.h
+++ b/third_party/WebKit/Source/wtf/HashTable.h
@@ -456,16 +456,17 @@ public:
void reserveCapacityForSize(unsigned size);
- AddResult add(ValuePassInType value)
+ template <typename IncomingValueType>
+ AddResult add(IncomingValueType&& value)
{
- return add<IdentityTranslatorType>(Extractor::extract(value), value);
+ return add<IdentityTranslatorType>(Extractor::extract(value), std::forward<IncomingValueType>(value));
}
// A special version of add() that finds the object by hashing and comparing
// with some other type, to avoid the cost of type conversion if the object
// is already in the table.
template <typename HashTranslator, typename T, typename Extra> AddResult add(T&& key, Extra&&);
- template <typename HashTranslator, typename T, typename Extra> AddResult addPassingHashCode(const T& key, const Extra&);
+ template <typename HashTranslator, typename T, typename Extra> AddResult addPassingHashCode(T&& key, Extra&&);
iterator find(KeyPeekInType key) { return find<IdentityTranslatorType>(key); }
const_iterator find(KeyPeekInType key) const { return find<IdentityTranslatorType>(key); }
@@ -863,7 +864,7 @@ typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo
template <typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator>
template <typename HashTranslator, typename T, typename Extra>
-typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::addPassingHashCode(const T& key, const Extra& extra)
+typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::addPassingHashCode(T&& key, Extra&& extra)
{
ASSERT(!m_accessForbidden);
ASSERT(Allocator::isAllocationAllowed());
@@ -886,7 +887,7 @@ typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo
--m_deletedCount;
}
- HashTranslator::translate(*entry, key, extra, h);
+ HashTranslator::translate(*entry, std::forward<T>(key), std::forward<Extra>(extra), h);
ASSERT(!isEmptyOrDeletedBucket(*entry));
++m_keyCount;
« no previous file with comments | « third_party/WebKit/Source/wtf/HashSetTest.cpp ('k') | third_party/WebKit/Source/wtf/text/AtomicString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698