Bug 870698 - Part 11: Replace Insert(NS_LITERAL_STRING("")) with InsertLiteral(u""). r=erahm
authorChris Peterson <cpeterson@mozilla.com>
Thu, 07 Sep 2017 18:08:18 -0700
changeset 382630 39ac3246ab5cbc25cd786b7405c6c6b77b9593eb
parent 382629 3857318b8a8815a42c7e3de5b272bc81bafdf5de
child 382631 0c137ff9d95e01b7a869b6a330290467a368452e
push id32569
push userarchaeopteryx@coole-files.de
push dateSun, 24 Sep 2017 21:52:51 +0000
treeherdermozilla-central@b44e80e0590e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs870698
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 870698 - Part 11: Replace Insert(NS_LITERAL_STRING("")) with InsertLiteral(u""). r=erahm The NS_LITERAL_STRING macro creates a temporary nsLiteralString to encapsulate the char16_t string literal and its length, but AssignLiteral() can determine the char16_t string literal's length at compile-time without nsLiteralString. MozReview-Commit-ID: L9UE3gXHG4Q
dom/base/nsContentUtils.cpp
layout/style/CounterStyleManager.cpp
modules/libpref/Preferences.cpp
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
toolkit/xre/nsNativeAppSupportWin.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -7188,17 +7188,17 @@ nsContentUtils::IsPatternMatching(nsAStr
   AutoJSContext cx;
   AutoDisableJSInterruptCallback disabler(cx);
 
   // We can use the junk scope here, because we're just using it for
   // regexp evaluation, not actual script execution.
   JSAutoCompartment ac(cx, xpc::UnprivilegedJunkScope());
 
   // The pattern has to match the entire value.
-  aPattern.Insert(NS_LITERAL_STRING("^(?:"), 0);
+  aPattern.InsertLiteral(u"^(?:", 0);
   aPattern.AppendLiteral(")$");
 
   JS::Rooted<JSObject*> re(cx,
     JS_NewUCRegExpObject(cx,
                          static_cast<char16_t*>(aPattern.BeginWriting()),
                          aPattern.Length(), JSREG_UNICODE));
   if (!re) {
     // Remove extra patterns added above to report with the original pattern.
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -487,17 +487,17 @@ EthiopicToText(CounterValue aOrdinal, ns
   uint8_t asciiStringLength = asciiNumberString.Length();
 
   // If number length is odd, add a leading "0"
   // the leading "0" preconditions the string to always have the
   // leading tens place populated, this avoids a check within the loop.
   // If we didn't add the leading "0", decrement asciiStringLength so
   // it will be equivalent to a zero-based index in both cases.
   if (asciiStringLength & 1) {
-    asciiNumberString.Insert(NS_LITERAL_STRING("0"), 0);
+    asciiNumberString.InsertLiteral(u"0", 0);
   } else {
     asciiStringLength--;
   }
 
   aResult.Truncate();
   // Iterate from the highest digits to lowest
   // indexFromLeft       indexes digits (0 = most significant)
   // groupIndexFromRight indexes pairs of digits (0 = least significant)
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -1153,17 +1153,17 @@ Preferences::ReadUserOverridePrefs()
 nsresult
 Preferences::MakeBackupPrefFile(nsIFile *aFile)
 {
   // Example: this copies "prefs.js" to "Invalidprefs.js" in the same directory.
   // "Invalidprefs.js" is removed if it exists, prior to making the copy.
   nsAutoString newFilename;
   nsresult rv = aFile->GetLeafName(newFilename);
   NS_ENSURE_SUCCESS(rv, rv);
-  newFilename.Insert(NS_LITERAL_STRING("Invalid"), 0);
+  newFilename.InsertLiteral(u"Invalid", 0);
   nsCOMPtr<nsIFile> newFile;
   rv = aFile->GetParent(getter_AddRefs(newFile));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = newFile->Append(newFilename);
   NS_ENSURE_SUCCESS(rv, rv);
   bool exists = false;
   newFile->Exists(&exists);
   if (exists) {
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -72,34 +72,34 @@ mozTXTToHTMLConv::EscapeStr(nsString& aI
   //aInString.ReplaceSubstring("<", "&lt;");
   //aInString.ReplaceSubstring(">", "&gt;");
   for (uint32_t i = 0; i < aInString.Length();)
   {
     switch (aInString[i])
     {
     case '<':
       aInString.Cut(i, 1);
-      aInString.Insert(NS_LITERAL_STRING("&lt;"), i);
+      aInString.InsertLiteral(u"&lt;", i);
       i += 4; // skip past the integers we just added
       break;
     case '>':
       aInString.Cut(i, 1);
-      aInString.Insert(NS_LITERAL_STRING("&gt;"), i);
+      aInString.InsertLiteral(u"&gt;", i);
       i += 4; // skip past the integers we just added
       break;
     case '&':
       aInString.Cut(i, 1);
-      aInString.Insert(NS_LITERAL_STRING("&amp;"), i);
+      aInString.InsertLiteral(u"&amp;", i);
       i += 5; // skip past the integers we just added
       break;
     case '"':
       if (inAttribute)
       {
         aInString.Cut(i, 1);
-        aInString.Insert(NS_LITERAL_STRING("&quot;"), i);
+        aInString.InsertLiteral(u"&quot;", i);
         i += 6;
         break;
       }
       // else fall through
       MOZ_FALLTHROUGH;
     default:
       i++;
     }
--- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
@@ -280,35 +280,35 @@ nsTXTToHTMLConv::CatHTML(int32_t front, 
         mBuffer.Cut(front, back - front);
         mBuffer.Insert(mToken->modText, front);
         cursor = front+modLen;
     } else {
         nsString linkText;
         // href is implied
         mBuffer.Mid(linkText, front, back-front);
 
-        mBuffer.Insert(NS_LITERAL_STRING("<a href=\""), front);
+        mBuffer.InsertLiteral(u"<a href=\"", front);
         cursor += front+9;
         if (modLen) {
             mBuffer.Insert(mToken->modText, cursor);
             cursor += modLen;
         }
 
         NS_ConvertUTF16toUTF8 linkTextUTF8(linkText);
         nsCString escaped;
         if (NS_EscapeURL(linkTextUTF8.Data(), linkTextUTF8.Length(), esc_Minimal, escaped)) {
             mBuffer.Cut(cursor, back - front);
             CopyUTF8toUTF16(escaped, linkText);
             mBuffer.Insert(linkText, cursor);
             back = front + linkText.Length();
         }
 
         cursor += back-front;
-        mBuffer.Insert(NS_LITERAL_STRING("\">"), cursor);
+        mBuffer.InsertLiteral(u"\">", cursor);
         cursor += 2;
         mBuffer.Insert(linkText, cursor);
         cursor += linkText.Length();
-        mBuffer.Insert(NS_LITERAL_STRING("</a>"), cursor);
+        mBuffer.InsertLiteral(u"</a>", cursor);
         cursor += 4;
     }
     mToken = nullptr; // indicates completeness
     return cursor;
 }
--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -920,20 +920,20 @@ nsNativeAppSupportWin::HandleDDENotifica
                     ParseDDEArg(hsz2, 0, url);
 
                     // Read the 3rd argument in the command to determine if a
                     // new window is to be used.
                     nsAutoString windowID;
                     ParseDDEArg(hsz2, 2, windowID);
                     // "" means to open the URL in a new window.
                     if ( windowID.IsEmpty() ) {
-                        url.Insert(NS_LITERAL_STRING("mozilla -new-window "), 0);
+                        url.InsertLiteral(u"mozilla -new-window ", 0);
                     }
                     else {
-                        url.Insert(NS_LITERAL_STRING("mozilla -url "), 0);
+                        url.InsertLiteral(u"mozilla -url ", 0);
                     }
 
 #if MOZ_DEBUG_DDE
                     printf( "Handling dde XTYP_REQUEST request: [%s]...\n", NS_ConvertUTF16toUTF8(url).get() );
 #endif
                     // Now handle it.
                     HandleCommandLine(NS_ConvertUTF16toUTF8(url).get(), nullptr, nsICommandLine::STATE_REMOTE_EXPLICIT);
 
@@ -1085,20 +1085,20 @@ nsNativeAppSupportWin::HandleDDENotifica
 
             // Read the 3rd argument in the command to determine if a
             // new window is to be used.
             nsAutoString windowID;
             ParseDDEArg((const WCHAR*) request, 2, windowID);
 
             // "" means to open the URL in a new window.
             if ( windowID.IsEmpty() ) {
-                url.Insert(NS_LITERAL_STRING("mozilla -new-window "), 0);
+                url.InsertLiteral(u"mozilla -new-window ", 0);
             }
             else {
-                url.Insert(NS_LITERAL_STRING("mozilla -url "), 0);
+                url.InsertLiteral(u"mozilla -url ", 0);
             }
 #if MOZ_DEBUG_DDE
             printf( "Handling dde XTYP_REQUEST request: [%s]...\n", NS_ConvertUTF16toUTF8(url).get() );
 #endif
             // Now handle it.
             HandleCommandLine(NS_ConvertUTF16toUTF8(url).get(), nullptr, nsICommandLine::STATE_REMOTE_EXPLICIT);
 
             // Release the data.
@@ -1481,9 +1481,8 @@ nsNativeAppSupportWin::OpenBrowserWindow
         (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
     NS_ENSURE_TRUE(cmdLine, NS_ERROR_FAILURE);
 
     rv = cmdLine->Init(0, argv, nullptr, nsICommandLine::STATE_REMOTE_EXPLICIT);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return cmdLine->Run();
 }
-