Bug 1263486 part 2 - Use nsCSSValue move assignment operator in nsCSSValue::Adopt(Pair)ListValue draft
authorBrian Birtles <birtles@gmail.com>
Fri, 20 May 2016 09:09:33 +0900
changeset 368985 a6742b5a8537abff793cd87e37d741572abc880f
parent 368984 51d71a5b0b4abd917c50ec3123206ab93f200077
child 368986 54d9e1570f668ecb7004f3ba9d103f51f8f0f0ab
push id18687
push userbbirtles@mozilla.com
push dateFri, 20 May 2016 00:11:47 +0000
bugs1263486
milestone49.0a1
Bug 1263486 part 2 - Use nsCSSValue move assignment operator in nsCSSValue::Adopt(Pair)ListValue MozReview-Commit-ID: 2fTFNmtHxIP
layout/style/nsCSSValue.cpp
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -6,16 +6,17 @@
 
 /* representation of simple property values within CSS declarations */
 
 #include "nsCSSValue.h"
 
 #include "mozilla/CSSStyleSheet.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/Move.h"
 #include "mozilla/css/ImageLoader.h"
 #include "CSSCalc.h"
 #include "gfxFontConstants.h"
 #include "imgIRequest.h"
 #include "imgRequestProxy.h"
 #include "nsIDocument.h"
 #include "nsIPrincipal.h"
 #include "nsCSSProps.h"
@@ -635,19 +636,17 @@ void nsCSSValue::SetDependentListValue(n
 }
 
 void
 nsCSSValue::AdoptListValue(UniquePtr<nsCSSValueList> aValue)
 {
   // We have to copy the first element since for owned lists the first
   // element should be an nsCSSValueList_heap object.
   SetListValue();
-  // FIXME: If nsCSSValue gets a swap method or move assignment operator,
-  // we should use that here to avoid allocating an extra value.
-  mValue.mList->mValue = aValue->mValue;
+  mValue.mList->mValue = Move(aValue->mValue);
   mValue.mList->mNext  = aValue->mNext;
   aValue->mNext = nullptr;
   aValue.reset();
 }
 
 nsCSSValuePairList* nsCSSValue::SetPairListValue()
 {
   Reset();
@@ -667,20 +666,18 @@ void nsCSSValue::SetDependentPairListVal
 }
 
 void
 nsCSSValue::AdoptPairListValue(UniquePtr<nsCSSValuePairList> aValue)
 {
   // We have to copy the first element, since for owned pair lists, the first
   // element should be an nsCSSValuePairList_heap object.
   SetPairListValue();
-  // FIXME: If nsCSSValue gets a swap method or move assignment operator,
-  // we should use that here to avoid allocating extra values.
-  mValue.mPairList->mXValue = aValue->mXValue;
-  mValue.mPairList->mYValue = aValue->mYValue;
+  mValue.mPairList->mXValue = Move(aValue->mXValue);
+  mValue.mPairList->mYValue = Move(aValue->mYValue);
   mValue.mPairList->mNext   = aValue->mNext;
   aValue->mNext = nullptr;
   aValue.reset();
 }
 
 void nsCSSValue::SetAutoValue()
 {
   Reset();