Bug 1461450 - Part 1: Add move constructors and assignment operators to nsTArray, r=froydnj
☠☠ backed out by e4f654755cc5 ☠ ☠
authorNika Layzell <nika@thelayzells.com>
Fri, 06 Jul 2018 19:26:59 -0400
changeset 429242 961379be0f5ec85db2483c537834f240bc37cd03
parent 429241 cf2448b2635f3bd34932914868e56671e8a9b551
child 429243 c721ada8a6d6d157c4e9eef6139c6ae92438b39e
push id67094
push userccoroiu@mozilla.com
push dateMon, 30 Jul 2018 22:02:32 +0000
treeherderautoland@397b4d841690 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1461450
milestone63.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 1461450 - Part 1: Add move constructors and assignment operators to nsTArray, r=froydnj
xpcom/ds/nsTArray.h
--- a/xpcom/ds/nsTArray.h
+++ b/xpcom/ds/nsTArray.h
@@ -2545,16 +2545,23 @@ public:
 
   AutoTArray(const self_type& aOther)
     : nsTArray<E>()
   {
     Init();
     this->AppendElements(aOther);
   }
 
+  AutoTArray(self_type&& aOther)
+    : nsTArray<E>()
+  {
+    Init();
+    this->SwapElements(aOther);
+  }
+
   explicit AutoTArray(const base_type& aOther)
     : mAlign()
   {
     Init();
     this->AppendElements(aOther);
   }
 
   explicit AutoTArray(base_type&& aOther)
@@ -2579,16 +2586,22 @@ public:
   }
 
   self_type& operator=(const self_type& aOther)
   {
     base_type::operator=(aOther);
     return *this;
   }
 
+  self_type& operator=(self_type&& aOther)
+  {
+    base_type::operator=(std::move(aOther));
+    return *this;
+  }
+
   template<typename Allocator>
   self_type& operator=(const nsTArray_Impl<elem_type, Allocator>& aOther)
   {
     base_type::operator=(aOther);
     return *this;
   }
 
 private: