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

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

Issue 1764973002: WTF::HashTable: Implement move semantics for keys and values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: third_party/WebKit/Source/wtf/HashTraits.h
diff --git a/third_party/WebKit/Source/wtf/HashTraits.h b/third_party/WebKit/Source/wtf/HashTraits.h
index d25e09db045c222809d5b43add0f5ddbb6a137fb..8cda7d9336bf751b5ca3a951c17aee27120489c4 100644
--- a/third_party/WebKit/Source/wtf/HashTraits.h
+++ b/third_party/WebKit/Source/wtf/HashTraits.h
@@ -107,11 +107,13 @@ template <typename T> struct GenericHashTraits : GenericHashTraitsBase<std::is_i
// The store function either not be called or called once to store something
// passed in. The value passed to the store function will be PassInType.
typedef const T& PassInType;
- static void store(const T& value, T& storage) { storage = value; }
+ template <typename IncomingValueType>
+ static void store(IncomingValueType&& value, T& storage) { storage = std::forward<IncomingValueType>(value); }
// Type for return value of functions that transfer ownership, such as take.
typedef T PassOutType;
- static const T& passOut(const T& value) { return value; }
+ static T&& passOut(T& value) { return std::move(value); }
Mikhail 2016/03/04 12:58:02 do we still need 'passOut'? can std::move be calle
Yuta Kitamura 2016/03/04 13:55:37 Other specializations (for e.g. PassRefPtr) still
+ static T&& passOut(T&& value) { return std::move(value); }
// Type for return value of functions that do not transfer ownership, such
// as get.
@@ -264,9 +266,10 @@ template <typename KeyTypeArg, typename ValueTypeArg>
struct KeyValuePair {
typedef KeyTypeArg KeyType;
- KeyValuePair(const KeyTypeArg& _key, const ValueTypeArg& _value)
- : key(_key)
- , value(_value)
+ template <typename IncomingKeyType, typename IncomingValueType>
+ KeyValuePair(IncomingKeyType&& key, IncomingValueType&& value)
+ : key(std::forward<IncomingKeyType>(key))
+ , value(std::forward<IncomingValueType>(value))
{
}
« third_party/WebKit/Source/wtf/HashTable.h ('K') | « third_party/WebKit/Source/wtf/HashTable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698