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

Unified Diff: Source/platform/Length.h

Issue 296403003: Add a move constructor and move assignment operator to Length (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comments Created 6 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/Length.h
diff --git a/Source/platform/Length.h b/Source/platform/Length.h
index 9104f3b4e2d89567b61c989713778b1553eaac5f..ac20386466be09ee8991a3ced3a60c7c8afc6f49 100644
--- a/Source/platform/Length.h
+++ b/Source/platform/Length.h
@@ -120,6 +120,36 @@ public:
return *this;
}
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ Length(Length&& length)
+ {
+ memcpy(this, &length, sizeof(Length));
+
+ // Reset |length|'s type to Auto to make sure its destructor
+ // won't call decrementCalculatedRef() as we don't call
+ // incrementCalculatedRef() here.
+ length.m_type = Auto;
+ }
+
+ Length& operator=(Length&& length)
+ {
+ if (this == &length)
+ return *this;
+
+ if (isCalculated())
+ decrementCalculatedRef();
+
+ memcpy(this, &length, sizeof(Length));
+
+ // Reset |length|'s type to Auto to make sure its destructor
+ // won't call decrementCalculatedRef() as we don't call
+ // incrementCalculatedRef() here.
+ length.m_type = Auto;
+
+ return *this;
+ }
+#endif
+
~Length()
{
if (isCalculated())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698