aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-12-15 15:13:13 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-15 21:31:26 +0000
commit6b00a07d4fa5f9fd2feb0fc50adac0ce6a477e41 (patch)
tree2706ad2353bf8f65201d4102d6f70e357e6b8242 /include/private
parentd0a0a652b455583a045b2c162fc613c19697834d (diff)
simplify SkTHash* move support
Don't know why I thought this had to be so complicated before. BUG=skia:6053 Change-Id: Ie714fed1cb47e9add166d4227d3d31f95eba2411 Reviewed-on: https://skia-review.googlesource.com/6121 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'include/private')
-rw-r--r--include/private/SkTHash.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/include/private/SkTHash.h b/include/private/SkTHash.h
index ea5d74c4e6..943129f8a9 100644
--- a/include/private/SkTHash.h
+++ b/include/private/SkTHash.h
@@ -50,13 +50,12 @@ public:
// Copy val into the hash table, returning a pointer to the copy now in the table.
// If there already is an entry in the table with the same key, we overwrite it.
- T* set(T&& val) {
+ T* set(T val) {
if (4 * fCount >= 3 * fCapacity) {
this->resize(fCapacity > 0 ? fCapacity * 2 : 4);
}
return this->uncheckedSet(std::move(val));
}
- T* set(const T& val) { return this->set(std::move(T(val))); }
// If there is an entry in the table with this key, return a pointer to it. If not, null.
T* find(const K& key) const {
@@ -236,11 +235,10 @@ public:
// Set key to val in the table, replacing any previous value with the same key.
// We copy both key and val, and return a pointer to the value copy now in the table.
- V* set(K&& key, V&& val) {
+ V* set(K key, V val) {
Pair* out = fTable.set({std::move(key), std::move(val)});
return &out->val;
}
- V* set(const K& key, const V& val) { return this->set(std::move(K(key)), std::move(V(val))); }
// If there is key/value entry in the table with this key, return a pointer to the value.
// If not, return null.
@@ -296,8 +294,7 @@ public:
size_t approxBytesUsed() const { return fTable.approxBytesUsed(); }
// Copy an item into the set.
- void add(T&& item) { fTable.set(std::move(item)); }
- void add(const T& item) { this->add(std::move(T(item))); }
+ void add(T item) { fTable.set(std::move(item)); }
// Is this item in the set?
bool contains(const T& item) const { return SkToBool(this->find(item)); }