[gjs: 7/15] mem: Only print counter totals if >0



commit f4fcfa8202f4160567138b173c1cbfb4a606674e
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Dec 15 23:12:50 2018 -0800

    mem: Only print counter totals if >0
    
    At the end of each successful test run we print out a useless list of
    all zeroes. We don't need to print out the counter totals unless they
    are nonzero; in the case where they are all zero we already print out
    "0 objects currently alive".
    
    We also increase the number of spaces printed out, since
    object_prototype already overflows the allotted 12 spaces.

 gjs/mem.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gjs/mem.cpp b/gjs/mem.cpp
index 4539a3db..c973397c 100644
--- a/gjs/mem.cpp
+++ b/gjs/mem.cpp
@@ -99,14 +99,13 @@ gjs_memory_report(const char *where,
               "  %d objects currently alive",
               GJS_GET_COUNTER(everything));
 
-    for (i = 0; i < n_counters; ++i) {
-        gjs_debug(GJS_DEBUG_MEMORY,
-                  "    %12s = %d",
-                  counters[i]->name,
-                  counters[i]->value);
-    }
-
-    if (die_if_leaks && GJS_GET_COUNTER(everything) > 0) {
-        g_error("%s: JavaScript objects were leaked.", where);
+    if (GJS_GET_COUNTER(everything) > 0) {
+        for (i = 0; i < n_counters; ++i) {
+            gjs_debug(GJS_DEBUG_MEMORY, "    %24s = %d", counters[i]->name,
+                      counters[i]->value);
+        }
+
+        if (die_if_leaks)
+            g_error("%s: JavaScript objects were leaked.", where);
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]