bug 977838 - move refify a11y::Relation r=surkov
authorTrevor Saunders <trev.saunders@gmail.com>
Thu, 27 Feb 2014 17:24:31 -0500
changeset 172400 4f08a24e4fb5e6c8cb7032b2bcfbe419125a3076
parent 172399 97e52c3f95ae810a6c39cbc625374d588823b9c9
child 172401 ea3ad950c01bc77f1635a867a3c3d8290514ff3d
push id26358
push usercbook@mozilla.com
push dateFri, 07 Mar 2014 11:48:31 +0000
treeherdermozilla-central@b9fc2eb18bd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs977838
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 977838 - move refify a11y::Relation r=surkov
accessible/src/base/Relation.h
--- a/accessible/src/base/Relation.h
+++ b/accessible/src/base/Relation.h
@@ -4,66 +4,53 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_a11y_relation_h_
 #define mozilla_a11y_relation_h_
 
 #include "AccIterator.h"
 
+#include "mozilla/Move.h"
+
 namespace mozilla {
 namespace a11y {
 
 /**
- * This class is used to return Relation objects from functions.  A copy
- * constructor doesn't work here because we need to mutate the old relation to
- * have its nsAutoPtr forget what it points to.
- */
-struct RelationCopyHelper
-{
-  RelationCopyHelper(AccIterable* aFirstIter, AccIterable* aLastIter) :
-    mFirstIter(aFirstIter), mLastIter(aLastIter) { }
-
-  AccIterable* mFirstIter;
-  AccIterable* mLastIter;
-};
-
-/**
  * A collection of relation targets of a certain type.  Targets are computed
  * lazily while enumerating.
  */
 class Relation
 {
 public:
   Relation() : mFirstIter(nullptr), mLastIter(nullptr) { }
 
-  Relation(const RelationCopyHelper aRelation) :
-    mFirstIter(aRelation.mFirstIter), mLastIter(aRelation.mLastIter) { }
-
   Relation(AccIterable* aIter) :
     mFirstIter(aIter), mLastIter(aIter) { }
 
   Relation(Accessible* aAcc) :
     mFirstIter(nullptr), mLastIter(nullptr)
     { AppendTarget(aAcc); }
 
   Relation(DocAccessible* aDocument, nsIContent* aContent) :
     mFirstIter(nullptr), mLastIter(nullptr)
     { AppendTarget(aDocument, aContent); }
 
-  Relation& operator = (const RelationCopyHelper& aRH)
+  Relation(Relation&& aOther) :
+    mFirstIter(Move(aOther.mFirstIter)), mLastIter(aOther.mLastIter)
   {
-    mFirstIter = aRH.mFirstIter;
-    mLastIter = aRH.mLastIter;
-    return *this;
+    aOther.mLastIter = nullptr;
   }
 
-  operator RelationCopyHelper()
+  Relation& operator = (Relation&& aRH)
   {
-    return RelationCopyHelper(mFirstIter.forget(), mLastIter);
+    mFirstIter = Move(aRH.mFirstIter);
+    mLastIter = aRH.mLastIter;
+    aRH.mLastIter = nullptr;
+    return *this;
   }
 
   inline void AppendIter(AccIterable* aIter)
   {
     if (mLastIter)
       mLastIter->mNextIter = aIter;
     else
       mFirstIter = aIter;
@@ -103,17 +90,18 @@ public:
 
     if (!mFirstIter)
       mLastIter = nullptr;
 
     return target;
   }
 
 private:
-  Relation& operator = (const Relation&);
+  Relation& operator = (const Relation&) MOZ_DELETE;
+  Relation(const Relation&) MOZ_DELETE;
 
   nsAutoPtr<AccIterable> mFirstIter;
   AccIterable* mLastIter;
 };
 
 } // namespace a11y
 } // namespace mozilla