Bug 1308995, part 5 - Use early return in NS_LogCtor/Dtor. r=froydnj
authorAndrew McCreight <continuation@gmail.com>
Mon, 10 Oct 2016 13:34:53 -0700
changeset 317456 07516ea470af1151bb9fc81504f5f92990307adf
parent 317455 2aeb18b3df71550b49e80ff3bb8d800e9c7ff675
child 317457 121afaaeb446ebe239f94535fdec44c8bb1f1bd7
push id30805
push usercbook@mozilla.com
push dateWed, 12 Oct 2016 10:00:08 +0000
treeherdermozilla-central@feb1c52ebe9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1308995
milestone52.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 1308995, part 5 - Use early return in NS_LogCtor/Dtor. r=froydnj This is an unrelated change to fix an issue that was bothering me. MozReview-Commit-ID: Cxw9WhHfSAf
xpcom/base/nsTraceRefcnt.cpp
--- a/xpcom/base/nsTraceRefcnt.cpp
+++ b/xpcom/base/nsTraceRefcnt.cpp
@@ -1136,76 +1136,80 @@ NS_LogRelease(void* aPtr, nsrefcnt aRefc
 EXPORT_XPCOM_API(void)
 NS_LogCtor(void* aPtr, const char* aType, uint32_t aInstanceSize)
 {
   ASSERT_ACTIVITY_IS_LEGAL;
   if (!gInitialized) {
     InitTraceLog();
   }
 
-  if (gLogging != NoLogging) {
-    AutoTraceLogLock lock;
+  if (gLogging == NoLogging) {
+    return;
+  }
 
-    if (gBloatLog) {
-      BloatEntry* entry = GetBloatEntry(aType, aInstanceSize);
-      if (entry) {
-        entry->Ctor();
-      }
-    }
+  AutoTraceLogLock lock;
 
-    bool loggingThisType = (!gTypesToLog || LogThisType(aType));
-    intptr_t serialno = 0;
-    if (gSerialNumbers && loggingThisType) {
-      serialno = GetSerialNumber(aPtr, true);
+  if (gBloatLog) {
+    BloatEntry* entry = GetBloatEntry(aType, aInstanceSize);
+    if (entry) {
+      entry->Ctor();
     }
+  }
 
-    bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));
-    if (gAllocLog && loggingThisType && loggingThisObject) {
-      fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Ctor (%d)\n",
-              aType, aPtr, serialno, aInstanceSize);
-      WalkTheStackCached(gAllocLog);
-    }
+  bool loggingThisType = (!gTypesToLog || LogThisType(aType));
+  intptr_t serialno = 0;
+  if (gSerialNumbers && loggingThisType) {
+    serialno = GetSerialNumber(aPtr, true);
+  }
+
+  bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));
+  if (gAllocLog && loggingThisType && loggingThisObject) {
+    fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Ctor (%d)\n",
+            aType, aPtr, serialno, aInstanceSize);
+    WalkTheStackCached(gAllocLog);
   }
 }
 
 
 EXPORT_XPCOM_API(void)
 NS_LogDtor(void* aPtr, const char* aType, uint32_t aInstanceSize)
 {
   ASSERT_ACTIVITY_IS_LEGAL;
   if (!gInitialized) {
     InitTraceLog();
   }
 
-  if (gLogging != NoLogging) {
-    AutoTraceLogLock lock;
+  if (gLogging == NoLogging) {
+    return;
+  }
+
+  AutoTraceLogLock lock;
 
-    if (gBloatLog) {
-      BloatEntry* entry = GetBloatEntry(aType, aInstanceSize);
-      if (entry) {
-        entry->Dtor();
-      }
+  if (gBloatLog) {
+    BloatEntry* entry = GetBloatEntry(aType, aInstanceSize);
+    if (entry) {
+      entry->Dtor();
     }
+  }
 
-    bool loggingThisType = (!gTypesToLog || LogThisType(aType));
-    intptr_t serialno = 0;
-    if (gSerialNumbers && loggingThisType) {
-      serialno = GetSerialNumber(aPtr, false);
-      RecycleSerialNumberPtr(aPtr);
-    }
+  bool loggingThisType = (!gTypesToLog || LogThisType(aType));
+  intptr_t serialno = 0;
+  if (gSerialNumbers && loggingThisType) {
+    serialno = GetSerialNumber(aPtr, false);
+    RecycleSerialNumberPtr(aPtr);
+  }
 
-    bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));
+  bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));
 
-    // (If we're on a losing architecture, don't do this because we'll be
-    // using LogDeleteXPCOM instead to get file and line numbers.)
-    if (gAllocLog && loggingThisType && loggingThisObject) {
-      fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Dtor (%d)\n",
-              aType, aPtr, serialno, aInstanceSize);
-      WalkTheStackCached(gAllocLog);
-    }
+  // (If we're on a losing architecture, don't do this because we'll be
+  // using LogDeleteXPCOM instead to get file and line numbers.)
+  if (gAllocLog && loggingThisType && loggingThisObject) {
+    fprintf(gAllocLog, "\n<%s> %p %" PRIdPTR " Dtor (%d)\n",
+            aType, aPtr, serialno, aInstanceSize);
+    WalkTheStackCached(gAllocLog);
   }
 }
 
 
 EXPORT_XPCOM_API(void)
 NS_LogCOMPtrAddRef(void* aCOMPtr, nsISupports* aObject)
 {
 #ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR