Bug 959485, part 5 - Remove success from nsJSCID::NewID. r=gabor
authorAndrew McCreight <continuation@gmail.com>
Fri, 17 Jan 2014 05:57:34 -0800
changeset 163947 b9757c55e79b9c917b760fe76b5156179872926e
parent 163946 54ddff6ebfa5da5bdea7d14520d49e187f696833
child 163948 0ed69fa19314301d0945280944137efa8c9bf2ab
push id38588
push useramccreight@mozilla.com
push dateFri, 17 Jan 2014 13:57:55 +0000
treeherdermozilla-inbound@2be8ad58c32e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs959485
milestone29.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 959485, part 5 - Remove success from nsJSCID::NewID. r=gabor
js/xpconnect/src/XPCJSID.cpp
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -612,34 +612,30 @@ already_AddRefed<nsJSCID>
 nsJSCID::NewID(const char* str)
 {
     if (!str) {
         NS_ERROR("no string");
         return nullptr;
     }
 
     nsRefPtr<nsJSCID> idObj = new nsJSCID();
-    bool success = false;
-
     if (str[0] == '{') {
-        if (NS_SUCCEEDED(idObj->Initialize(str)))
-            success = true;
+        NS_ENSURE_SUCCESS(idObj->Initialize(str), nullptr);
     } else {
         nsCOMPtr<nsIComponentRegistrar> registrar;
         NS_GetComponentRegistrar(getter_AddRefs(registrar));
-        if (registrar) {
-            nsCID *cid;
-            if (NS_SUCCEEDED(registrar->ContractIDToCID(str, &cid))) {
-                success = idObj->mDetails.InitWithName(*cid, str);
-                nsMemory::Free(cid);
-            }
-        }
+        NS_ENSURE_TRUE(registrar, nullptr);
+
+        nsCID *cid;
+        NS_ENSURE_SUCCESS(registrar->ContractIDToCID(str, &cid), nullptr);
+        bool success = idObj->mDetails.InitWithName(*cid, str);
+        nsMemory::Free(cid);
+        if (!success)
+            return nullptr;
     }
-    if (!success)
-        return nullptr;
     return idObj.forget();
 }
 
 static const nsID*
 GetIIDArg(uint32_t argc, const JS::Value& val, JSContext* cx)
 {
     const nsID* iid;