Bug 1073711: Clean up nsCacheService::CreateSessionInternal; drop useless null-check of 'this' and after 'new', and use nsRefPtr::forget(). r=mayhemer
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 03 Oct 2014 10:54:44 -0700
changeset 233307 3bea361c1f4014e09fdcee60db8b585b104acab9
parent 233306 eaa8c62e29f650fd254241f11b0862d3473230ad
child 233308 b1a9b31ab26e28c99b9583a31e5ea5c97f16aa68
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1073711
milestone35.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 1073711: Clean up nsCacheService::CreateSessionInternal; drop useless null-check of 'this' and after 'new', and use nsRefPtr::forget(). r=mayhemer
netwerk/cache/nsCacheService.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1318,22 +1318,19 @@ nsCacheService::CreateSession(const char
 }
 
 nsresult
 nsCacheService::CreateSessionInternal(const char *          clientID,
                                       nsCacheStoragePolicy  storagePolicy,
                                       bool                  streamBased,
                                       nsICacheSession     **result)
 {
-    if (this == nullptr)  return NS_ERROR_NOT_AVAILABLE;
-
-    nsCacheSession * session = new nsCacheSession(clientID, storagePolicy, streamBased);
-    if (!session)  return NS_ERROR_OUT_OF_MEMORY;
-
-    NS_ADDREF(*result = session);
+    nsRefPtr<nsCacheSession> session =
+        new nsCacheSession(clientID, storagePolicy, streamBased);
+    session.forget(result);
 
     return NS_OK;
 }
 
 
 nsresult
 nsCacheService::EvictEntriesForSession(nsCacheSession * session)
 {