From 569872924318662e738c14f30fb23dd1b7104fed Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Thu, 7 Sep 2017 18:32:54 -0700 Subject: [PATCH] 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 --HG-- extra : rebase_source : cf537a1f65af003c6c4f8919b925b0f305c1dd4d extra : source : 13b89ce4e6a66c840f82a335c71f5a12938aba22 --- accessible/base/Logging.cpp | 4 +-- dom/base/XPathGenerator.cpp | 8 +++--- dom/base/nsContentUtils.cpp | 2 +- dom/flyweb/FlyWebService.cpp | 4 +-- dom/security/nsCSPUtils.cpp | 6 ++-- layout/style/StyleRule.cpp | 2 +- netwerk/protocol/http/nsHttpChannel.cpp | 10 +++---- parser/html/nsHtml5ViewSourceUtils.cpp | 4 +-- security/apps/AppSignatureVerification.cpp | 2 +- .../components/telemetry/TelemetryScalar.cpp | 28 +++++++++---------- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp index 93148c12e1fb..601d03ade93e 100644 --- a/accessible/base/Logging.cpp +++ b/accessible/base/Logging.cpp @@ -686,7 +686,7 @@ logging::Tree(const char* aTitle, const char* aMsgText, 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; } @@ -724,7 +724,7 @@ logging::DOMTree(const char* aTitle, const char* aMsgText, printf("%s", NS_ConvertUTF16toUTF8(level).get()); logging::Node("", root); if (root->GetFirstChild()) { - level.Append(NS_LITERAL_STRING(" ")); + level.AppendLiteral(u" "); root = root->GetFirstChild(); continue; } diff --git a/dom/base/XPathGenerator.cpp b/dom/base/XPathGenerator.cpp index 974043cdf85c..1b1242be1a8b 100644 --- a/dom/base/XPathGenerator.cpp +++ b/dom/base/XPathGenerator.cpp @@ -83,7 +83,7 @@ void GenerateConcatExpression(const nsAString& aStr, nsAString& aResult) nonQuoteBeginPtr = nullptr; } if (!quoteBeginPtr) { - result.Append(NS_LITERAL_STRING("\',\"")); + result.AppendLiteral(u"\',\""); quoteBeginPtr = cur; } } else { @@ -92,7 +92,7 @@ void GenerateConcatExpression(const nsAString& aStr, nsAString& aResult) } if (quoteBeginPtr) { result.Append(quoteBeginPtr, cur - quoteBeginPtr); - result.Append(NS_LITERAL_STRING("\",\'")); + result.AppendLiteral(u"\",\'"); quoteBeginPtr = nullptr; } } @@ -100,7 +100,7 @@ void GenerateConcatExpression(const nsAString& aStr, nsAString& aResult) if (quoteBeginPtr) { result.Append(quoteBeginPtr, cur - quoteBeginPtr); - result.Append(NS_LITERAL_STRING("\",\'")); + result.AppendLiteral(u"\",\'"); } else if (nonQuoteBeginPtr) { result.Append(nonQuoteBeginPtr, cur - nonQuoteBeginPtr); } @@ -189,7 +189,7 @@ void XPathGenerator::Generate(const nsINode* aNode, nsAString& aResult) 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); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 854d0855f91e..701df19464d0 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -1635,7 +1635,7 @@ nsContentUtils::SandboxFlagsToString(uint32_t aFlags, nsAString& aString) #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)); \ } diff --git a/dom/flyweb/FlyWebService.cpp b/dom/flyweb/FlyWebService.cpp index eea30ec62166..efcda2f7eb78 100644 --- a/dom/flyweb/FlyWebService.cpp +++ b/dom/flyweb/FlyWebService.cpp @@ -802,11 +802,11 @@ FlyWebMDNSService::PairWithService(const nsAString& aServiceId, 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 uiURL; NS_NewURI(getter_AddRefs(uiURL), url); diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp index 7783b7ecfda8..ebccc8e347d8 100644 --- a/dom/security/nsCSPUtils.cpp +++ b/dom/security/nsCSPUtils.cpp @@ -142,7 +142,7 @@ CSP_LogMessage(const nsAString& aMessage, // 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 @@ -152,9 +152,9 @@ CSP_LogMessage(const nsAString& aMessage, // 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; diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index 3b04f6b5da56..9536abb69ba4 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -873,7 +873,7 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations if (list->mValueCaseSensitivity == nsAttrSelector::ValueCaseSensitivity::CaseInsensitive) { - aString.Append(NS_LITERAL_STRING(" i")); + aString.AppendLiteral(u" i"); } } diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 6c3b4ec30447..c6a7f9a6bfb4 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -6429,15 +6429,15 @@ nsHttpChannel::BeginConnect() 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()); } diff --git a/parser/html/nsHtml5ViewSourceUtils.cpp b/parser/html/nsHtml5ViewSourceUtils.cpp index d94865d0acee..29879572631b 100644 --- a/parser/html/nsHtml5ViewSourceUtils.cpp +++ b/parser/html/nsHtml5ViewSourceUtils.cpp @@ -18,10 +18,10 @@ nsHtml5ViewSourceUtils::NewBodyAttributes() 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( diff --git a/security/apps/AppSignatureVerification.cpp b/security/apps/AppSignatureVerification.cpp index 6121b1576d38..ccd78751e59f 100644 --- a/security/apps/AppSignatureVerification.cpp +++ b/security/apps/AppSignatureVerification.cpp @@ -1221,7 +1221,7 @@ CheckDirForUnsignedFiles(nsIFile* aDir, // 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 { diff --git a/toolkit/components/telemetry/TelemetryScalar.cpp b/toolkit/components/telemetry/TelemetryScalar.cpp index d4268d0ae3be..2bf6019ca6d9 100644 --- a/toolkit/components/telemetry/TelemetryScalar.cpp +++ b/toolkit/components/telemetry/TelemetryScalar.cpp @@ -805,46 +805,46 @@ internal_LogScalarError(const nsACString& aScalarName, ScalarResult aSr) 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.