From b98afa1d199343f3eac267c44fa0a0773dbfed3c Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Thu, 7 Sep 2017 18:08:18 -0700 Subject: [PATCH] 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 --HG-- extra : source : 37d74bf745b23542251cc6b021d6aabb5ffadea1 extra : intermediate-source : 0402b4bd34c293b44c76de22418899420c8e405b --- dom/base/nsContentUtils.cpp | 2 +- layout/style/CounterStyleManager.cpp | 2 +- modules/libpref/Preferences.cpp | 2 +- netwerk/streamconv/converters/mozTXTToHTMLConv.cpp | 8 ++++---- netwerk/streamconv/converters/nsTXTToHTMLConv.cpp | 6 +++--- toolkit/xre/nsNativeAppSupportWin.cpp | 9 ++++----- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 701df19464d05..38400575c76a4 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -7193,7 +7193,7 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern, 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 re(cx, diff --git a/layout/style/CounterStyleManager.cpp b/layout/style/CounterStyleManager.cpp index cc0175c3fa7b9..58bebf8d83deb 100644 --- a/layout/style/CounterStyleManager.cpp +++ b/layout/style/CounterStyleManager.cpp @@ -492,7 +492,7 @@ EthiopicToText(CounterValue aOrdinal, nsAString& aResult) // 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--; } diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index c0bb3efb194a1..c251ca4050d0d 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -1158,7 +1158,7 @@ Preferences::MakeBackupPrefFile(nsIFile *aFile) 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 newFile; rv = aFile->GetParent(getter_AddRefs(newFile)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index 13da28fa12264..d9f390a5c417b 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -77,24 +77,24 @@ mozTXTToHTMLConv::EscapeStr(nsString& aInString, bool inAttribute) { case '<': aInString.Cut(i, 1); - aInString.Insert(NS_LITERAL_STRING("<"), i); + aInString.InsertLiteral(u"<", i); i += 4; // skip past the integers we just added break; case '>': aInString.Cut(i, 1); - aInString.Insert(NS_LITERAL_STRING(">"), i); + aInString.InsertLiteral(u">", i); i += 4; // skip past the integers we just added break; case '&': aInString.Cut(i, 1); - aInString.Insert(NS_LITERAL_STRING("&"), i); + aInString.InsertLiteral(u"&", i); i += 5; // skip past the integers we just added break; case '"': if (inAttribute) { aInString.Cut(i, 1); - aInString.Insert(NS_LITERAL_STRING("""), i); + aInString.InsertLiteral(u""", i); i += 6; break; } diff --git a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp index ded3e9e6c5750..f75bed0f3c9af 100644 --- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp @@ -285,7 +285,7 @@ nsTXTToHTMLConv::CatHTML(int32_t front, int32_t back) // href is implied mBuffer.Mid(linkText, front, back-front); - mBuffer.Insert(NS_LITERAL_STRING("modText, cursor); @@ -302,11 +302,11 @@ nsTXTToHTMLConv::CatHTML(int32_t front, int32_t back) } 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(""), cursor); + mBuffer.InsertLiteral(u"", cursor); cursor += 4; } mToken = nullptr; // indicates completeness diff --git a/toolkit/xre/nsNativeAppSupportWin.cpp b/toolkit/xre/nsNativeAppSupportWin.cpp index d13569264bfa9..f1956ce0f258f 100755 --- a/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/toolkit/xre/nsNativeAppSupportWin.cpp @@ -925,10 +925,10 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t 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 @@ -1090,10 +1090,10 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t // "" 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() ); @@ -1486,4 +1486,3 @@ nsNativeAppSupportWin::OpenBrowserWindow() return cmdLine->Run(); } -