Bug 1344629 - Part 6: Rewrite unnecessary uses of nsLiteralString. r=dbaron

There's an antipattern where nsLiteralString is used as an unnecessary intermediary in converting from CharT* to CharT*,
e.g. CallAFunctionThatTakesACharPointer(NS_LITERAL_CSTRING("foo").get());
or
NS_NAMED_LITERAL_STRING(foo, "abc");
CallAFunctionThatTakesACharPointer(foo.get());

This patch rewrites the callsites that can be trivially changed to use char*/char16_t*.

I'd somewhat like to remove nsTLiteralString::get() altogether, but in code that's less straightforward than these examples, get() is useful enough to keep.

MozReview-Commit-ID: Kh1rUziVllo
This commit is contained in:
David Major
2017-03-14 15:26:27 +13:00
parent 00793fc67c
commit a660713d2b
27 changed files with 82 additions and 108 deletions

View File

@@ -166,14 +166,14 @@ nsWindowsShellService::ShortcutMaintenance()
if (NS_FAILED(taskbarInfo->GetDefaultGroupId(appId)))
return NS_ERROR_UNEXPECTED;
NS_NAMED_LITERAL_CSTRING(prefName, "browser.taskbar.lastgroupid");
const char* prefName = "browser.taskbar.lastgroupid";
nsCOMPtr<nsIPrefBranch> prefs =
do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!prefs)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsISupportsString> prefString;
rv = prefs->GetComplexValue(prefName.get(),
rv = prefs->GetComplexValue(prefName,
NS_GET_IID(nsISupportsString),
getter_AddRefs(prefString));
if (NS_SUCCEEDED(rv)) {
@@ -191,7 +191,7 @@ nsWindowsShellService::ShortcutMaintenance()
return rv;
prefString->SetData(appId);
rv = prefs->SetComplexValue(prefName.get(),
rv = prefs->SetComplexValue(prefName,
NS_GET_IID(nsISupportsString),
prefString);
if (NS_FAILED(rv)) {