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

Unified Diff: include/private/SkTDArray.h

Issue 2227673002: std::move(SkTDArray) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-08 (Monday) 09:19:06 EDT Created 4 years, 4 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
« no previous file with comments | « no previous file | src/core/SkAdvancedTypefaceMetrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 &&
« no previous file with comments | « no previous file | src/core/SkAdvancedTypefaceMetrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698