Bug 1377351 - Part 2: Add move overloads to nsA[C]String assignment and constructors, r=froydnj

MozReview-Commit-ID: 81U51pgshZI
This commit is contained in:
Nika Layzell 2017-10-02 10:58:15 -04:00
parent 1fe9edd088
commit 2ff829eabc
2 changed files with 51 additions and 0 deletions

View File

@ -98,6 +98,12 @@ public:
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)
{
@ -111,6 +117,13 @@ public:
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)
@ -128,6 +141,11 @@ public:
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)
@ -141,6 +159,11 @@ public:
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);
@ -603,6 +626,12 @@ public:
this->Assign(aStr);
}
nsTAutoStringN(self_type&& aStr)
: self_type()
{
this->Assign(mozilla::Move(aStr));
}
explicit
nsTAutoStringN(const substring_type& aStr)
: self_type()
@ -610,6 +639,13 @@ public:
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()
{
@ -640,11 +676,21 @@ public:
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);

View File

@ -258,6 +258,11 @@ public:
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);