Bug 1390036 (part 2) - Remove nsXPIDLString use from NullString(). r=dbaron.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 14 Aug 2017 14:46:53 +1000
changeset 375048 5e6de75921f1a41b02fbd2358edf3b23457105c9
parent 375047 bd7a1aa5db733489256e531e4e6c8bac9b4aae98
child 375049 30b4593d421308ef2ba9d608732cfcf707c77b55
push id32344
push usercbook@mozilla.com
push dateWed, 16 Aug 2017 09:23:42 +0000
treeherdermozilla-central@6ebc251bd288 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1390036
milestone57.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 1390036 (part 2) - Remove nsXPIDLString use from NullString(). r=dbaron. This requires adding a new constructor for ns[C]String that can be used to create an IsVoid string.
xpcom/string/nsReadableUtils.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/nsReadableUtils.cpp
+++ b/xpcom/string/nsReadableUtils.cpp
@@ -1273,17 +1273,17 @@ EmptyCString()
   static const nsDependentCString sEmpty((const char*)empty_buffer);
 
   return sEmpty;
 }
 
 const nsString&
 NullString()
 {
-  static const nsXPIDLString sNull;
+  static const nsString sNull(mozilla::detail::StringDataFlags::VOIDED);
 
   return sNull;
 }
 
 const nsCString&
 NullCString()
 {
   static const nsXPIDLCString sNull;
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -457,16 +457,25 @@ protected:
   // allow subclasses to initialize fields directly
   nsTString_CharT(char_type* aData, size_type aLength, DataFlags aDataFlags,
                   ClassFlags aClassFlags)
     : substring_type(aData, aLength, aDataFlags,
                      aClassFlags | ClassFlags::NULL_TERMINATED)
   {
   }
 
+  friend const nsTString_CharT& TNullString_CharT();
+
+  // Used by Null[C]String.
+  explicit nsTString_CharT(DataFlags aDataFlags)
+    : substring_type(char_traits::sEmptyBuffer, 0,
+                     aDataFlags | DataFlags::TERMINATED,
+                     ClassFlags::NULL_TERMINATED)
+  {}
+
   struct Segment {
     uint32_t mBegin, mLength;
     Segment(uint32_t aBegin, uint32_t aLength)
       : mBegin(aBegin)
       , mLength(aLength)
     {}
   };
 };
--- a/xpcom/string/string-template-def-char.h
+++ b/xpcom/string/string-template-def-char.h
@@ -20,8 +20,9 @@
 #define nsTDependentString_CharT            nsDependentCString
 #define nsTDependentSubstring_CharT         nsDependentCSubstring
 #define nsTLiteralString_CharT              nsLiteralCString
 #define nsTXPIDLString_CharT                nsXPIDLCString
 #define nsTGetterCopies_CharT               nsCGetterCopies
 #define nsTPromiseFlatString_CharT          nsPromiseFlatCString
 #define TPromiseFlatString_CharT            PromiseFlatCString
 #define nsTSubstringSplitter_CharT          nsCSubstringSplitter
+#define TNullString_CharT                   NullCString
--- a/xpcom/string/string-template-def-unichar.h
+++ b/xpcom/string/string-template-def-unichar.h
@@ -20,8 +20,9 @@
 #define nsTDependentString_CharT            nsDependentString
 #define nsTDependentSubstring_CharT         nsDependentSubstring
 #define nsTLiteralString_CharT              nsLiteralString
 #define nsTXPIDLString_CharT                nsXPIDLString
 #define nsTGetterCopies_CharT               nsGetterCopies
 #define nsTPromiseFlatString_CharT          nsPromiseFlatString
 #define TPromiseFlatString_CharT            PromiseFlatString
 #define nsTSubstringSplitter_CharT          nsSubstringSplitter
+#define TNullString_CharT                   NullString
--- a/xpcom/string/string-template-undef.h
+++ b/xpcom/string/string-template-undef.h
@@ -21,8 +21,9 @@
 #undef nsTDependentString_CharT
 #undef nsTDependentSubstring_CharT
 #undef nsTLiteralString_CharT
 #undef nsTXPIDLString_CharT
 #undef nsTGetterCopies_CharT
 #undef nsTPromiseFlatString_CharT
 #undef TPromiseFlatString_CharT
 #undef nsTSubstringSplitter_CharT
+#undef TNullString_CharT