Bug 870698 - Part 10: Replace Append(NS_LITERAL_STRING("")) with AppendLiteral(u""). r=erahm
authorChris Peterson <cpeterson@mozilla.com>
Thu, 07 Sep 2017 18:32:54 -0700
changeset 433384 3857318b8a8815a42c7e3de5b272bc81bafdf5de
parent 433383 a5b71c927db1ab9e3e32d58760ec497320d77340
child 433385 39ac3246ab5cbc25cd786b7405c6c6b77b9593eb
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [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 10: Replace Append(NS_LITERAL_STRING("")) with AppendLiteral(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: H9I6vNDMdIr
accessible/base/Logging.cpp
dom/base/XPathGenerator.cpp
dom/base/nsContentUtils.cpp
dom/flyweb/FlyWebService.cpp
dom/security/nsCSPUtils.cpp
layout/style/StyleRule.cpp
netwerk/protocol/http/nsHttpChannel.cpp
parser/html/nsHtml5ViewSourceUtils.cpp
security/apps/AppSignatureVerification.cpp
toolkit/components/telemetry/TelemetryScalar.cpp
--- a/accessible/base/Logging.cpp
+++ b/accessible/base/Logging.cpp
@@ -681,17 +681,17 @@ logging::Tree(const char* aTitle, const 
 
   nsAutoString level;
   Accessible* root = aRoot;
   do {
     const char* prefix = aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
     printf("%s", NS_ConvertUTF16toUTF8(level).get());
     logging::AccessibleInfo(prefix, root);
     if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
-      level.Append(NS_LITERAL_STRING("  "));
+      level.AppendLiteral(u"  ");
       root = root->FirstChild();
       continue;
     }
     int32_t idxInParent = root != aRoot && root->mParent ?
       root->mParent->mChildren.IndexOf(root) : -1;
     if (idxInParent != -1 &&
         idxInParent < static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
       root = root->mParent->mChildren.ElementAt(idxInParent + 1);
@@ -719,17 +719,17 @@ logging::DOMTree(const char* aTitle, con
 {
   logging::MsgBegin(aTitle, "%s", aMsgText);
   nsAutoString level;
   nsINode* root = aDocument->DocumentNode();
   do {
     printf("%s", NS_ConvertUTF16toUTF8(level).get());
     logging::Node("", root);
     if (root->GetFirstChild()) {
-      level.Append(NS_LITERAL_STRING("  "));
+      level.AppendLiteral(u"  ");
       root = root->GetFirstChild();
       continue;
     }
     if (root->GetNextSibling()) {
       root = root->GetNextSibling();
       continue;
     }
     while ((root = root->GetParentNode())) {
--- a/dom/base/XPathGenerator.cpp
+++ b/dom/base/XPathGenerator.cpp
@@ -78,34 +78,34 @@ void GenerateConcatExpression(const nsAS
   const char16_t* quoteBeginPtr = nullptr;
   for (; cur < end; ++cur) {
     if (char16_t('\'') == *cur) {
       if (nonQuoteBeginPtr) {
         result.Append(nonQuoteBeginPtr, cur - nonQuoteBeginPtr);
         nonQuoteBeginPtr = nullptr;
       }
       if (!quoteBeginPtr) {
-        result.Append(NS_LITERAL_STRING("\',\""));
+        result.AppendLiteral(u"\',\"");
         quoteBeginPtr = cur;
       }
     } else {
       if (!nonQuoteBeginPtr) {
         nonQuoteBeginPtr = cur;
       }
       if (quoteBeginPtr) {
         result.Append(quoteBeginPtr, cur - quoteBeginPtr);
-        result.Append(NS_LITERAL_STRING("\",\'"));
+        result.AppendLiteral(u"\",\'");
         quoteBeginPtr = nullptr;
       }
     }
   }
 
   if (quoteBeginPtr) {
     result.Append(quoteBeginPtr, cur - quoteBeginPtr);
-    result.Append(NS_LITERAL_STRING("\",\'"));
+    result.AppendLiteral(u"\",\'");
   } else if (nonQuoteBeginPtr) {
     result.Append(nonQuoteBeginPtr, cur - nonQuoteBeginPtr);
   }
 
   // Prepend concat(' and append ').
   aResult.Assign(NS_LITERAL_STRING("concat(\'") + result + NS_LITERAL_STRING("\')"));
 }
 
@@ -184,13 +184,13 @@ void XPathGenerator::Generate(const nsIN
   if (!nodeNameAttribute.IsEmpty()) {
     nsAutoString quotedArgument;
     QuoteArgument(nodeNameAttribute, quotedArgument);
     namePart.Assign(NS_LITERAL_STRING("[@name=") + quotedArgument + NS_LITERAL_STRING("]"));
   }
   if (count != 1) {
     countPart.AssignLiteral(u"[");
     countPart.AppendInt(count);
-    countPart.Append(NS_LITERAL_STRING("]"));
+    countPart.AppendLiteral(u"]");
   }
   Generate(aNode->GetParentNode(), aResult);
   aResult.Append(NS_LITERAL_STRING("/") + tag + namePart + countPart);
 }
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -1630,17 +1630,17 @@ nsContentUtils::SandboxFlagsToString(uin
     return;
   }
 
   aString.Truncate();
 
 #define SANDBOX_KEYWORD(string, atom, flags)                \
   if (!(aFlags & (flags))) {                                \
     if (!aString.IsEmpty()) {                               \
-      aString.Append(NS_LITERAL_STRING(" "));               \
+      aString.AppendLiteral(u" ");                          \
     }                                                       \
     aString.Append(nsDependentAtomString(nsGkAtoms::atom)); \
   }
 #include "IframeSandboxKeywordList.h"
 #undef SANDBOX_KEYWORD
 }
 
 nsIBidiKeyboard*
--- a/dom/flyweb/FlyWebService.cpp
+++ b/dom/flyweb/FlyWebService.cpp
@@ -797,21 +797,21 @@ FlyWebMDNSService::PairWithService(const
   if (discInfo->mService.mCert.IsEmpty()) {
     url.AssignLiteral("http://");
   } else {
     url.AssignLiteral("https://");
   }
   url.Append(aInfo->mService.mHostname);
   if (!discInfo->mService.mPath.IsEmpty()) {
     if (discInfo->mService.mPath.Find("/") != 0) {
-      url.Append(NS_LITERAL_STRING("/"));
+      url.AppendLiteral(u"/");
     }
     url.Append(discInfo->mService.mPath);
   } else {
-    url.Append(NS_LITERAL_STRING("/"));
+    url.AppendLiteral(u"/");
   }
   nsCOMPtr<nsIURI> uiURL;
   NS_NewURI(getter_AddRefs(uiURL), url);
   MOZ_ASSERT(uiURL);
   if (uiURL) {
     nsAutoCString spec;
     uiURL->GetSpec(spec);
     CopyUTF8toUTF16(spec, aInfo->mService.mUiUrl);
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -137,29 +137,29 @@ CSP_LogMessage(const nsAString& aMessage
   nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
 
   if (!console || !error) {
     return;
   }
 
   // Prepending CSP to the outgoing console message
   nsString cspMsg;
-  cspMsg.Append(NS_LITERAL_STRING("Content Security Policy: "));
+  cspMsg.AppendLiteral(u"Content Security Policy: ");
   cspMsg.Append(aMessage);
 
   // Currently 'aSourceLine' is not logged to the console, because similar
   // information is already included within the source link of the message.
   // For inline violations however, the line and column number are 0 and
   // information contained within 'aSourceLine' can be really useful for devs.
   // E.g. 'aSourceLine' might be: 'onclick attribute on DIV element'.
   // In such cases we append 'aSourceLine' directly to the error message.
   if (!aSourceLine.IsEmpty()) {
-    cspMsg.Append(NS_LITERAL_STRING(" Source: "));
+    cspMsg.AppendLiteral(" Source: ");
     cspMsg.Append(aSourceLine);
-    cspMsg.Append(NS_LITERAL_STRING("."));
+    cspMsg.AppendLiteral(u".");
   }
 
   nsresult rv;
   if (aInnerWindowID > 0) {
     nsCString catStr;
     catStr.AssignASCII(aCategory);
     rv = error->InitWithWindowID(cspMsg, aSourceName,
                                  aSourceLine, aLineNumber,
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -868,17 +868,17 @@ nsCSSSelector::AppendToStringWithoutComb
 
         aString.Append(char16_t('='));
 
         // Append the value
         nsStyleUtil::AppendEscapedCSSString(list->mValue, aString);
 
         if (list->mValueCaseSensitivity ==
               nsAttrSelector::ValueCaseSensitivity::CaseInsensitive) {
-          aString.Append(NS_LITERAL_STRING(" i"));
+          aString.AppendLiteral(u" i");
         }
       }
 
       aString.Append(char16_t(']'));
 
       list = list->mNext;
     }
   }
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6424,25 +6424,25 @@ nsHttpChannel::BeginConnect()
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
 
         nsCOMPtr<nsIConsoleService> consoleService =
             do_GetService(NS_CONSOLESERVICE_CONTRACTID);
         if (consoleService) {
             nsAutoString message(NS_LITERAL_STRING("Alternate Service Mapping found: "));
             AppendASCIItoUTF16(scheme.get(), message);
-            message.Append(NS_LITERAL_STRING("://"));
+            message.AppendLiteral(u"://");
             AppendASCIItoUTF16(host.get(), message);
-            message.Append(NS_LITERAL_STRING(":"));
+            message.AppendLiteral(u":");
             message.AppendInt(port);
-            message.Append(NS_LITERAL_STRING(" to "));
+            message.AppendLiteral(u" to ");
             AppendASCIItoUTF16(scheme.get(), message);
-            message.Append(NS_LITERAL_STRING("://"));
+            message.AppendLiteral(u"://");
             AppendASCIItoUTF16(mapping->AlternateHost().get(), message);
-            message.Append(NS_LITERAL_STRING(":"));
+            message.AppendLiteral(u":");
             message.AppendInt(mapping->AlternatePort());
             consoleService->LogStringMessage(message.get());
         }
 
         LOG(("nsHttpChannel %p Using connection info from altsvc mapping", this));
         mapping->GetConnectionInfo(getter_AddRefs(mConnectionInfo), proxyInfo, originAttributes);
         Telemetry::Accumulate(Telemetry::HTTP_TRANSACTION_USE_ALTSVC, true);
         Telemetry::Accumulate(Telemetry::HTTP_TRANSACTION_USE_ALTSVC_OE, !isHttps);
--- a/parser/html/nsHtml5ViewSourceUtils.cpp
+++ b/parser/html/nsHtml5ViewSourceUtils.cpp
@@ -13,20 +13,20 @@ nsHtml5HtmlAttributes*
 nsHtml5ViewSourceUtils::NewBodyAttributes()
 {
   nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
   nsHtml5String id = nsHtml5Portability::newStringFromLiteral("viewsource");
   bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id, -1);
 
   nsString klass;
   if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
-    klass.Append(NS_LITERAL_STRING("wrap "));
+    klass.AppendLiteral(u"wrap ");
   }
   if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) {
-    klass.Append(NS_LITERAL_STRING("highlight"));
+    klass.AppendLiteral(u"highlight");
   }
   if (!klass.IsEmpty()) {
     bodyAttrs->addAttribute(
       nsHtml5AttributeName::ATTR_CLASS, nsHtml5String::FromString(klass), -1);
   }
 
   int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4);
   if (tabSize > 0) {
--- a/security/apps/AppSignatureVerification.cpp
+++ b/security/apps/AppSignatureVerification.cpp
@@ -1216,17 +1216,17 @@ CheckDirForUnsignedFiles(nsIFile* aDir,
     bool isDir;
     rv = file->IsDirectory(&isDir);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     // if it's a directory we need to recurse
     if (isDir) {
-      curName.Append(NS_LITERAL_STRING("/"));
+      curName.AppendLiteral(u"/");
       rv = CheckDirForUnsignedFiles(file, curName, aItems,
                                     sigFilename, sfFilename, mfFilename);
     } else {
       // The files that comprise the signature mechanism are not covered by the
       // signature.
       //
       // XXX: This is OK for a single signature, but doesn't work for
       // multiple signatures because the metadata for the other signatures
--- a/toolkit/components/telemetry/TelemetryScalar.cpp
+++ b/toolkit/components/telemetry/TelemetryScalar.cpp
@@ -800,56 +800,56 @@ namespace {
 void
 internal_LogScalarError(const nsACString& aScalarName, ScalarResult aSr)
 {
   nsAutoString errorMessage;
   AppendUTF8toUTF16(aScalarName, errorMessage);
 
   switch (aSr) {
     case ScalarResult::NotInitialized:
-      errorMessage.Append(NS_LITERAL_STRING(" - Telemetry was not yet initialized."));
+      errorMessage.AppendLiteral(u" - Telemetry was not yet initialized.");
       break;
     case ScalarResult::CannotUnpackVariant:
-      errorMessage.Append(NS_LITERAL_STRING(" - Cannot convert the provided JS value to nsIVariant."));
+      errorMessage.AppendLiteral(u" - Cannot convert the provided JS value to nsIVariant.");
       break;
     case ScalarResult::CannotRecordInProcess:
-      errorMessage.Append(NS_LITERAL_STRING(" - Cannot record the scalar in the current process."));
+      errorMessage.AppendLiteral(u" - Cannot record the scalar in the current process.");
       break;
     case ScalarResult::KeyedTypeMismatch:
-      errorMessage.Append(NS_LITERAL_STRING(" - Attempting to manage a keyed scalar as a scalar (or vice-versa)."));
+      errorMessage.AppendLiteral(u" - Attempting to manage a keyed scalar as a scalar (or vice-versa).");
       break;
     case ScalarResult::UnknownScalar:
-      errorMessage.Append(NS_LITERAL_STRING(" - Unknown scalar."));
+      errorMessage.AppendLiteral(u" - Unknown scalar.");
       break;
     case ScalarResult::OperationNotSupported:
-      errorMessage.Append(NS_LITERAL_STRING(" - The requested operation is not supported on this scalar."));
+      errorMessage.AppendLiteral(u" - The requested operation is not supported on this scalar.");
       break;
     case ScalarResult::InvalidType:
-      errorMessage.Append(NS_LITERAL_STRING(" - Attempted to set the scalar to an invalid data type."));
+      errorMessage.AppendLiteral(u" - Attempted to set the scalar to an invalid data type.");
       break;
     case ScalarResult::InvalidValue:
-      errorMessage.Append(NS_LITERAL_STRING(" - Attempted to set the scalar to an incompatible value."));
+      errorMessage.AppendLiteral(u" - Attempted to set the scalar to an incompatible value.");
       break;
     case ScalarResult::StringTooLong:
-      errorMessage.Append(NS_LITERAL_STRING(" - Truncating scalar value to 50 characters."));
+      errorMessage.AppendLiteral(u" - Truncating scalar value to 50 characters.");
       break;
     case ScalarResult::KeyIsEmpty:
-      errorMessage.Append(NS_LITERAL_STRING(" - The key must not be empty."));
+      errorMessage.AppendLiteral(u" - The key must not be empty.");
       break;
     case ScalarResult::KeyTooLong:
-      errorMessage.Append(NS_LITERAL_STRING(" - The key length must be limited to 70 characters."));
+      errorMessage.AppendLiteral(u" - The key length must be limited to 70 characters.");
       break;
     case ScalarResult::TooManyKeys:
-      errorMessage.Append(NS_LITERAL_STRING(" - Keyed scalars cannot have more than 100 keys."));
+      errorMessage.AppendLiteral(u" - Keyed scalars cannot have more than 100 keys.");
       break;
     case ScalarResult::UnsignedNegativeValue:
-      errorMessage.Append(NS_LITERAL_STRING(" - Trying to set an unsigned scalar to a negative number."));
+      errorMessage.AppendLiteral(u" - Trying to set an unsigned scalar to a negative number.");
       break;
     case ScalarResult::UnsignedTruncatedValue:
-      errorMessage.Append(NS_LITERAL_STRING(" - Truncating float/double number."));
+      errorMessage.AppendLiteral(u" - Truncating float/double number.");
       break;
     default:
       // Nothing.
       return;
   }
 
   LogToBrowserConsole(nsIScriptError::warningFlag, errorMessage);
 }