Skip to content

Commit

Permalink
Bug 870698 - Part 11: Replace Insert(NS_LITERAL_STRING("")) with Inse…
Browse files Browse the repository at this point in the history
…rtLiteral(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
  • Loading branch information
cpeterso committed Sep 8, 2017
1 parent 5698729 commit b98afa1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<JSObject*> re(cx,
Expand Down
2 changes: 1 addition & 1 deletion layout/style/CounterStyleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/libpref/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<nsIFile> newFile;
rv = aFile->GetParent(getter_AddRefs(newFile));
NS_ENSURE_SUCCESS(rv, rv);
Expand Down
8 changes: 4 additions & 4 deletions netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ mozTXTToHTMLConv::EscapeStr(nsString& aInString, bool inAttribute)
{
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;
}
Expand Down
6 changes: 3 additions & 3 deletions netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<a href=\""), front);
mBuffer.InsertLiteral(u"<a href=\"", front);
cursor += front+9;
if (modLen) {
mBuffer.Insert(mToken->modText, cursor);
Expand All @@ -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("</a>"), cursor);
mBuffer.InsertLiteral(u"</a>", cursor);
cursor += 4;
}
mToken = nullptr; // indicates completeness
Expand Down
9 changes: 4 additions & 5 deletions toolkit/xre/nsNativeAppSupportWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -1486,4 +1486,3 @@ nsNativeAppSupportWin::OpenBrowserWindow()

return cmdLine->Run();
}

0 comments on commit b98afa1

Please sign in to comment.