From 725d5ad257898c23ef27f4d7feaa545103932c03 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Thu, 14 Jun 2018 15:54:29 -0400 Subject: SkTHashTable no longer uses SkNoncopy Change-Id: I0944195d3087c97353994ff219f77464d94f1ba8 Reviewed-on: https://skia-review.googlesource.com/135045 Commit-Queue: Hal Canary Commit-Queue: Mike Klein Auto-Submit: Hal Canary Reviewed-by: Mike Klein --- include/private/SkTHash.h | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/include/private/SkTHash.h b/include/private/SkTHash.h index d790284b0d..06e63a2113 100644 --- a/include/private/SkTHash.h +++ b/include/private/SkTHash.h @@ -23,15 +23,27 @@ // If the key is large and stored inside T, you may want to make K a const&. // Similarly, if T is large you might want it to be a pointer. template -class SkTHashTable : SkNoncopyable { +class SkTHashTable { public: SkTHashTable() : fCount(0), fCapacity(0) {} + SkTHashTable(SkTHashTable&& other) + : fCount(other.fCount) + , fCapacity(other.fCapacity) + , fSlots(std::move(other.fSlots)) { other.fCount = other.fCapacity = 0; } + + SkTHashTable& operator=(SkTHashTable&& other) { + if (this != &other) { + this->~SkTHashTable(); + new (this) SkTHashTable(std::move(other)); + } + return *this; + } + + SkTHashTable(const SkTHashTable&) = delete; + SkTHashTable& operator=(const SkTHashTable&) = delete; // Clear the table. - void reset() { - this->~SkTHashTable(); - new (this) SkTHashTable; - } + void reset() { *this = SkTHashTable(); } // How many entries are in the table? int count() const { return fCount; } @@ -220,9 +232,13 @@ private: // Maps K->V. A more user-friendly wrapper around SkTHashTable, suitable for most use cases. // K and V are treated as ordinary copyable C++ types, with no assumed relationship between the two. template -class SkTHashMap : SkNoncopyable { +class SkTHashMap { public: SkTHashMap() {} + SkTHashMap(SkTHashMap&&) = default; + SkTHashMap(const SkTHashMap&) = delete; + SkTHashMap& operator=(SkTHashMap&&) = default; + SkTHashMap& operator=(const SkTHashMap&) = delete; // Clear the map. void reset() { fTable.reset(); } @@ -282,9 +298,13 @@ private: // A set of T. T is treated as an ordinary copyable C++ type. template -class SkTHashSet : SkNoncopyable { +class SkTHashSet { public: SkTHashSet() {} + SkTHashSet(SkTHashSet&&) = default; + SkTHashSet(const SkTHashSet&) = delete; + SkTHashSet& operator=(SkTHashSet&&) = default; + SkTHashSet& operator=(const SkTHashSet&) = delete; // Clear the set. void reset() { fTable.reset(); } -- cgit v1.2.3