Bug 1164622 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=ekr
authorEric Rahm <erahm@mozilla.com>
Thu, 14 May 2015 10:13:24 -0700
changeset 243819 d65f1ee84fbbef36ea9e72dddedca5f28d468d92
parent 243818 ced96b3a9ac733cffb116a1ef0b2c50b5e463bd2
child 243820 dd750b3d18c5c96a0a04069eefd8bca79dac14d2
push id28753
push userkwierso@gmail.com
push dateThu, 14 May 2015 22:33:43 +0000
treeherdermozilla-central@07e2e15703cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs1164622
milestone41.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 1164622 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=ekr Avoid using a stringstream if the given log level is not enabled.
media/mtransport/logging.h
--- a/media/mtransport/logging.h
+++ b/media/mtransport/logging.h
@@ -24,13 +24,16 @@
     static PRLogModuleInfo* log;                \
     if (!log)                                   \
       log = PR_NewLogModule(n);                 \
     return log;                                 \
   }
 
 #define MOZ_MTLOG(level, b) \
   do {                                                                  \
-    std::stringstream str;                                              \
-    str << b;                                                           \
-    PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); } while(0)
+    if (PR_LOG_TEST(getLogModule(), level)) {                           \
+      std::stringstream str;                                            \
+      str << b;                                                         \
+      PR_LOG(getLogModule(), level, ("%s", str.str().c_str()));         \
+    }                                                                   \
+  } while(0)
 
 #endif // logging_h__