Bug 869836 - Part 1: Use EqualsLiteral instead of `== NS_LITERAL_STRING(...)`. r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 22 May 2014 06:48:50 +0300
changeset 203569 2970d506fa3a00283ad18eb29e6af24d1fdc5e43
parent 203568 863a0fc463fad45b607974121c5e9aa5b8a1d532
child 203570 eb77a9a1ee9b00f4b85f20bca52c9d0f50739b4a
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs869836
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 869836 - Part 1: Use EqualsLiteral instead of `== NS_LITERAL_STRING(...)`. r=ehsan
image/decoders/icon/win/nsIconChannel.cpp
layout/printing/nsPrintPreviewListener.cpp
netwerk/protocol/about/nsAboutCacheEntry.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/test/TestCookie.cpp
parser/htmlparser/src/nsParser.cpp
widget/xpwidgets/GfxInfoBase.cpp
xpcom/base/nsMemoryInfoDumper.cpp
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -53,21 +53,17 @@ struct ICONENTRY {
   uint16_t ieBitCount;
   uint32_t ieSizeImage;
   uint32_t ieFileOffset;
 };
 
 // Match stock icons with names
 static SHSTOCKICONID GetStockIconIDForName(const nsACString &aStockName)
 {
-  // UAC shield icon
-  if (aStockName == NS_LITERAL_CSTRING("uac-shield"))
-    return SIID_SHIELD;
-
-  return SIID_INVALID;
+  return aStockName.EqualsLiteral("uac-shield") ? SIID_SHIELD : SIID_INVALID;
 }
 
 // nsIconChannel methods
 nsIconChannel::nsIconChannel()
 {
 }
 
 nsIconChannel::~nsIconChannel() 
--- a/layout/printing/nsPrintPreviewListener.cpp
+++ b/layout/printing/nsPrintPreviewListener.cpp
@@ -165,17 +165,17 @@ nsPrintPreviewListener::HandleEvent(nsID
   if (content && !content->IsXUL()) {
     eEventAction action = ::GetActionForEvent(aEvent);
     switch (action) {
       case eEventAction_Tab:
       case eEventAction_ShiftTab:
       {
         nsAutoString eventString;
         aEvent->GetType(eventString);
-        if (eventString == NS_LITERAL_STRING("keydown")) {
+        if (eventString.EqualsLiteral("keydown")) {
           // Handle tabbing explicitly here since we don't want focus ending up
           // inside the content document, bug 244128.
           nsIDocument* doc = content->GetCurrentDoc();
           NS_ASSERTION(doc, "no document");
 
           nsIDocument* parentDoc = doc->GetParentDocument();
           NS_ASSERTION(parentDoc, "no parent document");
 
--- a/netwerk/protocol/about/nsAboutCacheEntry.cpp
+++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp
@@ -155,17 +155,17 @@ nsAboutCacheEntry::OpenCacheEntry(nsIURI
     nsresult rv;
 
     rv = ParseURI(uri, mStorageName, getter_AddRefs(mLoadInfo),
                        mEnhanceId, getter_AddRefs(mCacheURI));
     if (NS_FAILED(rv)) return rv;
 
     if (!CacheObserver::UseNewCache() &&
         mLoadInfo->IsPrivate() &&
-        mStorageName == NS_LITERAL_CSTRING("disk")) {
+        mStorageName.EqualsLiteral("disk")) {
         // The cache v1 is storing all private entries in the memory-only
         // cache, so it would not be found in the v1 disk cache.
         mStorageName = NS_LITERAL_CSTRING("memory");
     }
 
     return OpenCacheEntry();
 }
 
@@ -272,17 +272,17 @@ nsAboutCacheEntry::OnCacheEntryAvailable
 {
     nsresult rv;
 
     mWaitingForData = false;
     if (entry) {
         rv = WriteCacheEntryDescription(entry);
     } else if (!CacheObserver::UseNewCache() &&
                !mLoadInfo->IsPrivate() &&
-               mStorageName == NS_LITERAL_CSTRING("memory")) {
+               mStorageName.EqualsLiteral("memory")) {
         // If we were not able to find the entry in the memory storage
         // try again in the disk storage.
         // This is a workaround for cache v1: when an originally disk
         // cache entry is recreated as memory-only, it's clientID doesn't
         // change and we cannot find it in "HTTP-memory-only" session.
         // "Disk" cache storage looks at "HTTP".
         mStorageName = NS_LITERAL_CSTRING("disk");
         rv = OpenCacheEntry();
--- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
@@ -776,17 +776,17 @@ nsWyciwygChannel::ReadFromCache()
   nsresult rv;
 
   // Get the stored security info
   mCacheEntry->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
 
   nsAutoCString tmpStr;
   rv = mCacheEntry->GetMetaDataElement("inhibit-persistent-caching",
                                        getter_Copies(tmpStr));
-  if (NS_SUCCEEDED(rv) && tmpStr == NS_LITERAL_CSTRING("1"))
+  if (NS_SUCCEEDED(rv) && tmpStr.EqualsLiteral("1"))
     mLoadFlags |= INHIBIT_PERSISTENT_CACHING;
 
   // Get a transport to the cached data...
   rv = mCacheEntry->OpenInputStream(0, getter_AddRefs(mCacheInputStream));
   if (NS_FAILED(rv))
     return rv;
   NS_ENSURE_TRUE(mCacheInputStream, NS_ERROR_UNEXPECTED);
 
--- a/netwerk/test/TestCookie.cpp
+++ b/netwerk/test/TestCookie.cpp
@@ -648,19 +648,19 @@ main(int32_t argc, char *argv[])
         if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break;
         ++i;
         
         // keep tabs on the second and third cookies, so we can check them later
         nsCOMPtr<nsICookie2> cookie2(do_QueryInterface(cookie));
         if (!cookie2) break;
         nsAutoCString name;
         cookie2->GetName(name);
-        if (name == NS_LITERAL_CSTRING("test2"))
+        if (name.EqualsLiteral("test2"))
           expiredCookie = cookie2;
-        else if (name == NS_LITERAL_CSTRING("test3"))
+        else if (name.EqualsLiteral("test3"))
           newDomainCookie = cookie2;
       }
       rv[5] = i == 3;
       // check the httpOnly attribute of the second cookie is honored
       GetACookie(cookieService, "http://cookiemgr.test/foo/", nullptr, getter_Copies(cookie));
       rv[6] = CheckResult(cookie.get(), MUST_CONTAIN, "test2=yes");
       GetACookieNoHttp(cookieService, "http://cookiemgr.test/foo/", getter_Copies(cookie));
       rv[7] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test2=yes");
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -657,17 +657,17 @@ DetermineHTMLParseMode(const nsString& a
                !(resultFlags & PARSE_DTD_HAVE_PUBLIC_ID)) {
       // A doctype with an internal subset is always full_standards.
       // A doctype without a public ID is always full_standards.
       aDocType = eHTML_Strict;
       aParseMode = eDTDMode_full_standards;
 
       // Special hack for IBM's custom DOCTYPE.
       if (!(resultFlags & PARSE_DTD_HAVE_INTERNAL_SUBSET) &&
-          sysIDUCS2 == NS_LITERAL_STRING(
+          sysIDUCS2.EqualsLiteral(
                "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")) {
         aParseMode = eDTDMode_quirks;
         aDocType = eHTML_Quirks;
       }
 
     } else {
       // We have to check our list of public IDs to see what to do.
       // Yes, we want UCS2 to ASCII lossy conversion.
--- a/widget/xpwidgets/GfxInfoBase.cpp
+++ b/widget/xpwidgets/GfxInfoBase.cpp
@@ -201,41 +201,41 @@ BlacklistNodeToTextValue(nsIDOMNode *aBl
   aValue = value;
 
   return true;
 }
 
 static OperatingSystem
 BlacklistOSToOperatingSystem(const nsAString& os)
 {
-  if (os == NS_LITERAL_STRING("WINNT 5.1"))
+  if (os.EqualsLiteral("WINNT 5.1"))
     return DRIVER_OS_WINDOWS_XP;
-  else if (os == NS_LITERAL_STRING("WINNT 5.2"))
+  else if (os.EqualsLiteral("WINNT 5.2"))
     return DRIVER_OS_WINDOWS_SERVER_2003;
-  else if (os == NS_LITERAL_STRING("WINNT 6.0"))
+  else if (os.EqualsLiteral("WINNT 6.0"))
     return DRIVER_OS_WINDOWS_VISTA;
-  else if (os == NS_LITERAL_STRING("WINNT 6.1"))
+  else if (os.EqualsLiteral("WINNT 6.1"))
     return DRIVER_OS_WINDOWS_7;
-  else if (os == NS_LITERAL_STRING("WINNT 6.2"))
+  else if (os.EqualsLiteral("WINNT 6.2"))
     return DRIVER_OS_WINDOWS_8;
-  else if (os == NS_LITERAL_STRING("WINNT 6.3"))
+  else if (os.EqualsLiteral("WINNT 6.3"))
     return DRIVER_OS_WINDOWS_8_1;
-  else if (os == NS_LITERAL_STRING("Linux"))
+  else if (os.EqualsLiteral("Linux"))
     return DRIVER_OS_LINUX;
-  else if (os == NS_LITERAL_STRING("Darwin 9"))
+  else if (os.EqualsLiteral("Darwin 9"))
     return DRIVER_OS_OS_X_10_5;
-  else if (os == NS_LITERAL_STRING("Darwin 10"))
+  else if (os.EqualsLiteral("Darwin 10"))
     return DRIVER_OS_OS_X_10_6;
-  else if (os == NS_LITERAL_STRING("Darwin 11"))
+  else if (os.EqualsLiteral("Darwin 11"))
     return DRIVER_OS_OS_X_10_7;
-  else if (os == NS_LITERAL_STRING("Darwin 12"))
+  else if (os.EqualsLiteral("Darwin 12"))
     return DRIVER_OS_OS_X_10_8;
-  else if (os == NS_LITERAL_STRING("Android"))
+  else if (os.EqualsLiteral("Android"))
     return DRIVER_OS_ANDROID;
-  else if (os == NS_LITERAL_STRING("All"))
+  else if (os.EqualsLiteral("All"))
     return DRIVER_OS_ALL;
 
   return DRIVER_OS_UNKNOWN;
 }
 
 static GfxDeviceFamily*
 BlacklistDevicesToDeviceFamily(nsIDOMHTMLCollection* aDevices)
 {
@@ -260,78 +260,78 @@ BlacklistDevicesToDeviceFamily(nsIDOMHTM
   }
 
   return deviceIds;
 }
 
 static int32_t
 BlacklistFeatureToGfxFeature(const nsAString& aFeature)
 {
-  if (aFeature == NS_LITERAL_STRING("DIRECT2D"))
+  if (aFeature.EqualsLiteral("DIRECT2D"))
     return nsIGfxInfo::FEATURE_DIRECT2D;
-  else if (aFeature == NS_LITERAL_STRING("DIRECT3D_9_LAYERS"))
+  else if (aFeature.EqualsLiteral("DIRECT3D_9_LAYERS"))
     return nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS;
-  else if (aFeature == NS_LITERAL_STRING("DIRECT3D_10_LAYERS"))
+  else if (aFeature.EqualsLiteral("DIRECT3D_10_LAYERS"))
     return nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS;
-  else if (aFeature == NS_LITERAL_STRING("DIRECT3D_10_1_LAYERS"))
+  else if (aFeature.EqualsLiteral("DIRECT3D_10_1_LAYERS"))
     return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS;
-  else if (aFeature == NS_LITERAL_STRING("DIRECT3D_11_LAYERS"))
+  else if (aFeature.EqualsLiteral("DIRECT3D_11_LAYERS"))
     return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS;
-  else if (aFeature == NS_LITERAL_STRING("OPENGL_LAYERS"))
+  else if (aFeature.EqualsLiteral("OPENGL_LAYERS"))
     return nsIGfxInfo::FEATURE_OPENGL_LAYERS;
-  else if (aFeature == NS_LITERAL_STRING("WEBGL_OPENGL"))
+  else if (aFeature.EqualsLiteral("WEBGL_OPENGL"))
     return nsIGfxInfo::FEATURE_WEBGL_OPENGL;
-  else if (aFeature == NS_LITERAL_STRING("WEBGL_ANGLE"))
+  else if (aFeature.EqualsLiteral("WEBGL_ANGLE"))
     return nsIGfxInfo::FEATURE_WEBGL_ANGLE;
-  else if (aFeature == NS_LITERAL_STRING("WEBGL_MSAA"))
+  else if (aFeature.EqualsLiteral("WEBGL_MSAA"))
     return nsIGfxInfo::FEATURE_WEBGL_MSAA;
-  else if (aFeature == NS_LITERAL_STRING("STAGEFRIGHT"))
+  else if (aFeature.EqualsLiteral("STAGEFRIGHT"))
     return nsIGfxInfo::FEATURE_STAGEFRIGHT;
   return 0;
 }
 
 static int32_t
 BlacklistFeatureStatusToGfxFeatureStatus(const nsAString& aStatus)
 {
-  if (aStatus == NS_LITERAL_STRING("NO_INFO"))
+  if (aStatus.EqualsLiteral("NO_INFO"))
     return nsIGfxInfo::FEATURE_NO_INFO;
-  else if (aStatus == NS_LITERAL_STRING("BLOCKED_DRIVER_VERSION"))
+  else if (aStatus.EqualsLiteral("BLOCKED_DRIVER_VERSION"))
     return nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
-  else if (aStatus == NS_LITERAL_STRING("BLOCKED_DEVICE"))
+  else if (aStatus.EqualsLiteral("BLOCKED_DEVICE"))
     return nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
-  else if (aStatus == NS_LITERAL_STRING("DISCOURAGED"))
+  else if (aStatus.EqualsLiteral("DISCOURAGED"))
     return nsIGfxInfo::FEATURE_DISCOURAGED;
-  else if (aStatus == NS_LITERAL_STRING("BLOCKED_OS_VERSION"))
+  else if (aStatus.EqualsLiteral("BLOCKED_OS_VERSION"))
     return nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
 
   // Do not allow it to set STATUS_UNKNOWN.
 
   return nsIGfxInfo::FEATURE_NO_INFO;
 }
 
 static VersionComparisonOp
 BlacklistComparatorToComparisonOp(const nsAString& op)
 {
-  if (op == NS_LITERAL_STRING("LESS_THAN"))
+  if (op.EqualsLiteral("LESS_THAN"))
     return DRIVER_LESS_THAN;
-  else if (op == NS_LITERAL_STRING("LESS_THAN_OR_EQUAL"))
+  else if (op.EqualsLiteral("LESS_THAN_OR_EQUAL"))
     return DRIVER_LESS_THAN_OR_EQUAL;
-  else if (op == NS_LITERAL_STRING("GREATER_THAN"))
+  else if (op.EqualsLiteral("GREATER_THAN"))
     return DRIVER_GREATER_THAN;
-  else if (op == NS_LITERAL_STRING("GREATER_THAN_OR_EQUAL"))
+  else if (op.EqualsLiteral("GREATER_THAN_OR_EQUAL"))
     return DRIVER_GREATER_THAN_OR_EQUAL;
-  else if (op == NS_LITERAL_STRING("EQUAL"))
+  else if (op.EqualsLiteral("EQUAL"))
     return DRIVER_EQUAL;
-  else if (op == NS_LITERAL_STRING("NOT_EQUAL"))
+  else if (op.EqualsLiteral("NOT_EQUAL"))
     return DRIVER_NOT_EQUAL;
-  else if (op == NS_LITERAL_STRING("BETWEEN_EXCLUSIVE"))
+  else if (op.EqualsLiteral("BETWEEN_EXCLUSIVE"))
     return DRIVER_BETWEEN_EXCLUSIVE;
-  else if (op == NS_LITERAL_STRING("BETWEEN_INCLUSIVE"))
+  else if (op.EqualsLiteral("BETWEEN_INCLUSIVE"))
     return DRIVER_BETWEEN_INCLUSIVE;
-  else if (op == NS_LITERAL_STRING("BETWEEN_INCLUSIVE_START"))
+  else if (op.EqualsLiteral("BETWEEN_INCLUSIVE_START"))
     return DRIVER_BETWEEN_INCLUSIVE_START;
 
   return DRIVER_COMPARISON_IGNORED;
 }
 
 // Arbitrarily returns the first |tagname| child of |element|.
 static bool
 BlacklistNodeGetChildByName(nsIDOMElement *element,
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -181,28 +181,28 @@ void doGCCCDump(const uint8_t aRecvSig)
 #endif // MOZ_SUPPORTS_RT_SIGNALS }
 
 #if defined(MOZ_SUPPORTS_FIFO) // {
 namespace {
 
 void
 doMemoryReport(const nsCString& aInputStr)
 {
-  bool doMMUMemoryReport = aInputStr == NS_LITERAL_CSTRING("minimize memory report");
+  bool doMMUMemoryReport = aInputStr.EqualsLiteral("minimize memory report");
   LOG("FifoWatcher(command:%s) dispatching memory report runnable.", aInputStr.get());
   nsRefPtr<DumpMemoryInfoToTempDirRunnable> runnable =
     new DumpMemoryInfoToTempDirRunnable(/* identifier = */ EmptyString(),
                                         doMMUMemoryReport);
   NS_DispatchToMainThread(runnable);
 }
 
 void
 doGCCCDump(const nsCString& aInputStr)
 {
-  bool doAllTracesGCCCDump = aInputStr == NS_LITERAL_CSTRING("gc log");
+  bool doAllTracesGCCCDump = aInputStr.EqualsLiteral("gc log");
   LOG("FifoWatcher(command:%s) dispatching GC/CC log runnable.", aInputStr.get());
   nsRefPtr<GCAndCCLogDumpRunnable> runnable =
     new GCAndCCLogDumpRunnable(/* identifier = */ EmptyString(),
                                doAllTracesGCCCDump,
                                /* dumpChildProcesses = */ true);
   NS_DispatchToMainThread(runnable);
 }