Bug 1448586 - Avoid useless use of NS_LITERAL_CSTRING when prefixing query string with question mark. r=smaug.
authorHenri Sivonen <hsivonen@hsivonen.fi>
Sat, 24 Mar 2018 21:16:51 +0200
changeset 1465403 04f9d83550c253f3c0bce669a556ce1f0d15cee4
parent 1464483 868bd92df11a52d4f6732f8fc6afeb2a36b6313c
child 1465404 0429f4d52d8a7e0b5c67e0bd4fa8a6dd9d2e0c53
push id261084
push usermgaudet@mozilla.com
push dateMon, 26 Mar 2018 22:22:06 +0000
treeherdertry@f4a479b8850b [default view] [failures only]
reviewerssmaug
bugs1448586
milestone61.0a1
Bug 1448586 - Avoid useless use of NS_LITERAL_CSTRING when prefixing query string with question mark. r=smaug. MozReview-Commit-ID: Cy8zkNWjsXM
dom/base/Link.cpp
dom/url/URLMainThread.cpp
dom/url/URLWorker.cpp
--- a/dom/base/Link.cpp
+++ b/dom/base/Link.cpp
@@ -732,17 +732,18 @@ Link::GetSearch(nsAString &_search)
     // Do not throw!  Not having a valid URI or URL should result in an empty
     // string.
     return;
   }
 
   nsAutoCString search;
   nsresult rv = url->GetQuery(search);
   if (NS_SUCCEEDED(rv) && !search.IsEmpty()) {
-    CopyUTF8toUTF16(NS_LITERAL_CSTRING("?") + search, _search);
+    _search.Assign(u'?');
+    AppendUTF8toUTF16(search, _search);
   }
 }
 
 void
 Link::GetPort(nsAString &_port)
 {
   _port.Truncate();
 
--- a/dom/url/URLMainThread.cpp
+++ b/dom/url/URLMainThread.cpp
@@ -422,17 +422,18 @@ URLMainThread::GetSearch(nsAString& aSea
   // Do not throw!  Not having a valid URI or URL should result in an empty
   // string.
 
   nsAutoCString search;
   nsresult rv;
 
   rv = mURI->GetQuery(search);
   if (NS_SUCCEEDED(rv) && !search.IsEmpty()) {
-    CopyUTF8toUTF16(NS_LITERAL_CSTRING("?") + search, aSearch);
+    aSearch.Assign(u'?');
+    AppendUTF8toUTF16(search, aSearch);
   }
 }
 
 void
 URLMainThread::GetHash(nsAString& aHash, ErrorResult& aRv) const
 {
   aHash.Truncate();
 
--- a/dom/url/URLWorker.cpp
+++ b/dom/url/URLWorker.cpp
@@ -1110,17 +1110,18 @@ URLWorker::GetSearch(nsAString& aSearch,
   aSearch.Truncate();
 
   if (mStdURL) {
     nsAutoCString search;
     nsresult rv;
 
     rv = mStdURL->GetQuery(search);
     if (NS_SUCCEEDED(rv) && !search.IsEmpty()) {
-      CopyUTF8toUTF16(NS_LITERAL_CSTRING("?") + search, aSearch);
+      aSearch.Assign(u'?');
+      AppendUTF8toUTF16(search, aSearch);
     }
     return;
   }
 
   MOZ_ASSERT(mURLProxy);
   RefPtr<GetterRunnable> runnable =
     new GetterRunnable(mWorkerPrivate, GetterRunnable::GetterSearch, aSearch,
                        mURLProxy);