Index: include/private/SkTDArray.h |
diff --git a/include/private/SkTDArray.h b/include/private/SkTDArray.h |
index 8af54bbcc5bb58382ff739201999ad1d40f93bfc..d6ef3a3834141d4d1ee14021617926169fdfbe4b 100644 |
--- a/include/private/SkTDArray.h |
+++ b/include/private/SkTDArray.h |
@@ -14,10 +14,7 @@ |
template <typename T> class SkTDArray { |
public: |
- SkTDArray() { |
- fReserve = fCount = 0; |
- fArray = NULL; |
- } |
+ SkTDArray() : fArray(nullptr), fReserve(0), fCount(0) {} |
SkTDArray(const T src[], int count) { |
SkASSERT(src || count == 0); |
@@ -29,12 +26,13 @@ public: |
fReserve = fCount = count; |
} |
} |
- SkTDArray(const SkTDArray<T>& src) { |
- fReserve = fCount = 0; |
- fArray = NULL; |
+ SkTDArray(const SkTDArray<T>& src) : fArray(nullptr), fReserve(0), fCount(0) { |
SkTDArray<T> tmp(src.fArray, src.fCount); |
this->swap(tmp); |
} |
+ SkTDArray(SkTDArray<T>&& src) : fArray(nullptr), fReserve(0), fCount(0) { |
+ this->swap(src); |
+ } |
~SkTDArray() { |
sk_free(fArray); |
} |
@@ -51,6 +49,13 @@ public: |
} |
return *this; |
} |
+ SkTDArray<T>& operator=(SkTDArray<T>&& src) { |
+ if (this != &src) { |
+ this->swap(src); |
+ src.reset(); |
+ } |
+ return *this; |
+ } |
friend bool operator==(const SkTDArray<T>& a, const SkTDArray<T>& b) { |
return a.fCount == b.fCount && |