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

Unified Diff: src/core/SkString.cpp

Issue 1672123002: Make SkString movable. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Don't need 'this' on 'f' fields. Created 4 years, 10 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 | « include/core/SkString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkString.cpp
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index b5655e0503be9574f93047dc54f9158b343c25fc..8ac56744747049479a004de6308aba901e97c2e2 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -275,6 +275,13 @@ SkString::SkString(const SkString& src) {
fRec = RefRec(src.fRec);
}
+SkString::SkString(SkString&& src) {
+ src.validate();
+
+ fRec = src.fRec;
+ src.fRec = const_cast<Rec*>(&gEmptyRec);
+}
+
SkString::~SkString() {
this->validate();
@@ -310,6 +317,15 @@ SkString& SkString::operator=(const SkString& src) {
return *this;
}
+SkString& SkString::operator=(SkString&& src) {
+ this->validate();
+
+ if (fRec != src.fRec) {
+ this->swap(src);
+ }
+ return *this;
+}
+
SkString& SkString::operator=(const char text[]) {
this->validate();
« no previous file with comments | « include/core/SkString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698