aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-06-14 15:54:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-14 20:30:24 +0000
commit725d5ad257898c23ef27f4d7feaa545103932c03 (patch)
tree8528daa8a3efb8f6dc6b795d34c5c8932b40bd18 /include/private
parentddaf5a5768ce38198a54df841dfc3aed6dde7f55 (diff)
SkTHashTable no longer uses SkNoncopy
Change-Id: I0944195d3087c97353994ff219f77464d94f1ba8 Reviewed-on: https://skia-review.googlesource.com/135045 Commit-Queue: Hal Canary <halcanary@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Hal Canary <halcanary@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'include/private')
-rw-r--r--include/private/SkTHash.h34
1 files 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 <typename T, typename K, typename Traits = T>
-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 <typename K, typename V, typename HashK = SkGoodHash>
-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 <typename T, typename HashT = SkGoodHash>
-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(); }