Bug 1384834 (part 3) - Remove nsAdopting[C]String. r=erahm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 28 Jul 2017 11:21:49 +1000
changeset 420869 f3b45d52b78e2757f26559033bdb476e22c35159
parent 420868 d1f258975b80a9cef336962987cdf33113a8ddb2
child 420870 d6e8c5e46a872611ddbe8703980212d5daf2984f
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1384834
milestone56.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 1384834 (part 3) - Remove nsAdopting[C]String. r=erahm.
xpcom/string/nsTString.cpp
xpcom/string/nsTString.h
xpcom/string/string-template-def-char.h
xpcom/string/string-template-def-unichar.h
xpcom/string/string-template-undef.h
--- a/xpcom/string/nsTString.cpp
+++ b/xpcom/string/nsTString.cpp
@@ -1,41 +1,14 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-nsTAdoptingString_CharT&
-nsTAdoptingString_CharT::operator=(const self_type& str)
-{
-  // This'll violate the constness of this argument, that's just
-  // the nature of this class...
-  self_type* mutable_str = const_cast<self_type*>(&str);
-
-  if (str.mDataFlags & DataFlags::OWNED) {
-    // We want to do what Adopt() does, but without actually incrementing
-    // the Adopt count.  Note that we can be a little more straightforward
-    // about this than Adopt() is, because we know that str.mData is
-    // non-null.  Should we be able to assert that str is not void here?
-    NS_ASSERTION(str.mData, "String with null mData?");
-    Finalize();
-    SetData(str.mData, str.mLength, DataFlags::TERMINATED | DataFlags::OWNED);
-
-    // Make str forget the buffer we just took ownership of.
-    new (mutable_str) self_type();
-  } else {
-    Assign(str);
-
-    mutable_str->Truncate();
-  }
-
-  return *this;
-}
-
 void
 nsTString_CharT::Rebind(const char_type* data, size_type length)
 {
   // If we currently own a buffer, release it.
   Finalize();
 
   SetData(const_cast<char_type*>(data), length, DataFlags::TERMINATED);
   AssertValidDependentString();
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -813,66 +813,8 @@ private:
 };
 
 inline nsTGetterCopies_CharT
 getter_Copies(nsTSubstring_CharT& aString)
 {
   return nsTGetterCopies_CharT(aString);
 }
 
-
-/**
- * nsTAdoptingString extends nsTXPIDLString such that:
- *
- * (1) Adopt given string on construction or assignment, i.e. take
- * the value of what's given, and make what's given forget its
- * value. Note that this class violates constness in a few
- * places. Be careful!
- */
-class nsTAdoptingString_CharT : public nsTXPIDLString_CharT
-{
-public:
-
-  typedef nsTAdoptingString_CharT self_type;
-
-public:
-
-  explicit nsTAdoptingString_CharT()
-  {
-  }
-  explicit nsTAdoptingString_CharT(char_type* aStr,
-                                   size_type aLength = size_type(-1))
-  {
-    Adopt(aStr, aLength);
-  }
-
-  // copy-constructor required to adopt on copy. Note that this
-  // will violate the constness of |aStr| in the operator=()
-  // call. |aStr| will be truncated as a side-effect of this
-  // constructor.
-  nsTAdoptingString_CharT(const self_type& aStr)
-    : nsTXPIDLString_CharT()
-  {
-    *this = aStr;
-  }
-
-  // |operator=| does not inherit, so we must define our own
-  self_type& operator=(const substring_type& aStr)
-  {
-    Assign(aStr);
-    return *this;
-  }
-  self_type& operator=(const substring_tuple_type& aTuple)
-  {
-    Assign(aTuple);
-    return *this;
-  }
-
-  // Adopt(), if possible, when assigning to a self_type&. Note
-  // that this violates the constness of aStr, aStr is always
-  // truncated when this operator is called.
-  self_type& operator=(const self_type& aStr);
-
-private:
-  self_type& operator=(const char_type* aData) = delete;
-  self_type& operator=(char_type* aData) = delete;
-};
-
--- a/xpcom/string/string-template-def-char.h
+++ b/xpcom/string/string-template-def-char.h
@@ -17,12 +17,11 @@
 #define nsTSubstringTuple_CharT             nsCSubstringTuple
 #define nsTStringComparator_CharT           nsCStringComparator
 #define nsTDefaultStringComparator_CharT    nsDefaultCStringComparator
 #define nsTDependentString_CharT            nsDependentCString
 #define nsTDependentSubstring_CharT         nsDependentCSubstring
 #define nsTLiteralString_CharT              nsLiteralCString
 #define nsTXPIDLString_CharT                nsXPIDLCString
 #define nsTGetterCopies_CharT               nsCGetterCopies
-#define nsTAdoptingString_CharT             nsAdoptingCString
 #define nsTPromiseFlatString_CharT          nsPromiseFlatCString
 #define TPromiseFlatString_CharT            PromiseFlatCString
 #define nsTSubstringSplitter_CharT          nsCSubstringSplitter
--- a/xpcom/string/string-template-def-unichar.h
+++ b/xpcom/string/string-template-def-unichar.h
@@ -17,12 +17,11 @@
 #define nsTSubstringTuple_CharT             nsSubstringTuple
 #define nsTStringComparator_CharT           nsStringComparator
 #define nsTDefaultStringComparator_CharT    nsDefaultStringComparator
 #define nsTDependentString_CharT            nsDependentString
 #define nsTDependentSubstring_CharT         nsDependentSubstring
 #define nsTLiteralString_CharT              nsLiteralString
 #define nsTXPIDLString_CharT                nsXPIDLString
 #define nsTGetterCopies_CharT               nsGetterCopies
-#define nsTAdoptingString_CharT             nsAdoptingString
 #define nsTPromiseFlatString_CharT          nsPromiseFlatString
 #define TPromiseFlatString_CharT            PromiseFlatString
 #define nsTSubstringSplitter_CharT          nsSubstringSplitter
--- a/xpcom/string/string-template-undef.h
+++ b/xpcom/string/string-template-undef.h
@@ -18,12 +18,11 @@
 #undef nsTSubstringTuple_CharT
 #undef nsTStringComparator_CharT
 #undef nsTDefaultStringComparator_CharT
 #undef nsTDependentString_CharT
 #undef nsTDependentSubstring_CharT
 #undef nsTLiteralString_CharT
 #undef nsTXPIDLString_CharT
 #undef nsTGetterCopies_CharT
-#undef nsTAdoptingString_CharT
 #undef nsTPromiseFlatString_CharT
 #undef TPromiseFlatString_CharT
 #undef nsTSubstringSplitter_CharT