Bug 1377351 - Part 2: Add move overloads to nsA[C]String assignment and constructors, r=froydnj
authorNika Layzell <nika@thelayzells.com>
Mon, 02 Oct 2017 10:58:15 -0400
changeset 387001 4b8f494ccca34f595e929b0808eea935d81b1368
parent 387000 bf17a82ef4a95ba298fd8275102a6d3e895ba12d
child 387002 2f081c8282658b9977e595be588ab2eb5523b012
push id32705
push userryanvm@gmail.com
push dateThu, 19 Oct 2017 01:01:49 +0000
treeherdermozilla-central@a21099ce055f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1377351
milestone58.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 1377351 - Part 2: Add move overloads to nsA[C]String assignment and constructors, r=froydnj MozReview-Commit-ID: 81U51pgshZI
xpcom/string/nsTString.h
xpcom/string/nsTSubstring.h
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -93,29 +93,42 @@ public:
 #endif
 
   nsTString(const self_type& aStr)
     : substring_type(ClassFlags::NULL_TERMINATED)
   {
     this->Assign(aStr);
   }
 
+  nsTString(self_type&& aStr)
+    : substring_type(ClassFlags::NULL_TERMINATED)
+  {
+    this->Assign(mozilla::Move(aStr));
+  }
+
   MOZ_IMPLICIT nsTString(const substring_tuple_type& aTuple)
     : substring_type(ClassFlags::NULL_TERMINATED)
   {
     this->Assign(aTuple);
   }
 
   explicit
   nsTString(const substring_type& aReadable)
     : substring_type(ClassFlags::NULL_TERMINATED)
   {
     this->Assign(aReadable);
   }
 
+  explicit
+  nsTString(substring_type&& aReadable)
+    : substring_type(ClassFlags::NULL_TERMINATED)
+  {
+    this->Assign(mozilla::Move(aReadable));
+  }
+
 
   // |operator=| does not inherit, so we must define our own
   self_type& operator=(char_type aChar)
   {
     this->Assign(aChar);
     return *this;
   }
   self_type& operator=(const char_type* aData)
@@ -123,29 +136,39 @@ public:
     this->Assign(aData);
     return *this;
   }
   self_type& operator=(const self_type& aStr)
   {
     this->Assign(aStr);
     return *this;
   }
+  self_type& operator=(self_type&& aStr)
+  {
+    this->Assign(mozilla::Move(aStr));
+    return *this;
+  }
 #if defined(MOZ_USE_CHAR16_WRAPPER)
   template <typename EnableIfChar16 = IsChar16>
   self_type& operator=(const char16ptr_t aStr)
   {
     this->Assign(static_cast<const char16_t*>(aStr));
     return *this;
   }
 #endif
   self_type& operator=(const substring_type& aStr)
   {
     this->Assign(aStr);
     return *this;
   }
+  self_type& operator=(substring_type&& aStr)
+  {
+    this->Assign(mozilla::Move(aStr));
+    return *this;
+  }
   self_type& operator=(const substring_tuple_type& aTuple)
   {
     this->Assign(aTuple);
     return *this;
   }
 
   /**
    * returns the null-terminated string
@@ -598,23 +621,36 @@ public:
 #endif
 
   nsTAutoStringN(const self_type& aStr)
     : self_type()
   {
     this->Assign(aStr);
   }
 
+  nsTAutoStringN(self_type&& aStr)
+    : self_type()
+  {
+    this->Assign(mozilla::Move(aStr));
+  }
+
   explicit
   nsTAutoStringN(const substring_type& aStr)
     : self_type()
   {
     this->Assign(aStr);
   }
 
+  explicit
+  nsTAutoStringN(substring_type&& aStr)
+    : self_type()
+  {
+    this->Assign(mozilla::Move(aStr));
+  }
+
   MOZ_IMPLICIT nsTAutoStringN(const substring_tuple_type& aTuple)
     : self_type()
   {
     this->Assign(aTuple);
   }
 
   // |operator=| does not inherit, so we must define our own
   self_type& operator=(char_type aChar)
@@ -635,21 +671,31 @@ public:
     return *this;
   }
 #endif
   self_type& operator=(const self_type& aStr)
   {
     this->Assign(aStr);
     return *this;
   }
+  self_type& operator=(self_type&& aStr)
+  {
+    this->Assign(mozilla::Move(aStr));
+    return *this;
+  }
   self_type& operator=(const substring_type& aStr)
   {
     this->Assign(aStr);
     return *this;
   }
+  self_type& operator=(substring_type&& aStr)
+  {
+    this->Assign(mozilla::Move(aStr));
+    return *this;
+  }
   self_type& operator=(const substring_tuple_type& aTuple)
   {
     this->Assign(aTuple);
     return *this;
   }
 
   static const size_t kStorageSize = N;
 
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -253,16 +253,21 @@ public:
     return *this;
   }
 #endif
   self_type& operator=(const self_type& aStr)
   {
     Assign(aStr);
     return *this;
   }
+  self_type& operator=(self_type&& aStr)
+  {
+    Assign(mozilla::Move(aStr));
+    return *this;
+  }
   self_type& operator=(const substring_tuple_type& aTuple)
   {
     Assign(aTuple);
     return *this;
   }
 
   // Adopt a heap-allocated char sequence for this string; is Voided if aData
   // is null. Useful for e.g. converting an strdup'd C string into an