Bug 1163192 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Mon, 11 May 2015 13:56:59 -0700
changeset 243403 b8498d290c8a283cf78ab869a2b3390283ec9f86
parent 243402 1649cf3ead36ddb7f26a6a5311da64fe08ed7c39
child 243404 49ac06aeb3a8c4b4d63ea0c7d9e2c29e04524313
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1163192
milestone40.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 1163192 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj Check that logging is enabled before performing potentially expensive operations.
dom/xslt/xslt/txStylesheet.cpp
--- a/dom/xslt/xslt/txStylesheet.cpp
+++ b/dom/xslt/xslt/txStylesheet.cpp
@@ -152,37 +152,39 @@ txStylesheet::findTemplate(const txXPath
 #if defined(TX_TO_STRING)
                     match = templ.mMatch;
 #endif
                 }
             }
         }
     }
 
-    nsAutoString mode, nodeName;
-    if (aMode.mLocalName) {
-        aMode.mLocalName->ToString(mode);
-    }
-    txXPathNodeUtils::getNodeName(aNode, nodeName);
-    if (matchTemplate) {
-        nsAutoString matchAttr;
+    if (PR_LOG_TEST(txLog::xslt, PR_LOG_DEBUG)) {
+      nsAutoString mode, nodeName;
+      if (aMode.mLocalName) {
+          aMode.mLocalName->ToString(mode);
+      }
+      txXPathNodeUtils::getNodeName(aNode, nodeName);
+      if (matchTemplate) {
+          nsAutoString matchAttr;
 #ifdef TX_TO_STRING
-        match->toString(matchAttr);
+          match->toString(matchAttr);
 #endif
-        PR_LOG(txLog::xslt, PR_LOG_DEBUG,
-               ("MatchTemplate, Pattern %s, Mode %s, Node %s\n",
-                NS_LossyConvertUTF16toASCII(matchAttr).get(),
-                NS_LossyConvertUTF16toASCII(mode).get(),
-                NS_LossyConvertUTF16toASCII(nodeName).get()));
-    }
-    else {
-        PR_LOG(txLog::xslt, PR_LOG_DEBUG,
-               ("No match, Node %s, Mode %s\n", 
-                NS_LossyConvertUTF16toASCII(nodeName).get(),
-                NS_LossyConvertUTF16toASCII(mode).get()));
+          PR_LOG(txLog::xslt, PR_LOG_DEBUG,
+                 ("MatchTemplate, Pattern %s, Mode %s, Node %s\n",
+                  NS_LossyConvertUTF16toASCII(matchAttr).get(),
+                  NS_LossyConvertUTF16toASCII(mode).get(),
+                  NS_LossyConvertUTF16toASCII(nodeName).get()));
+      }
+      else {
+          PR_LOG(txLog::xslt, PR_LOG_DEBUG,
+                 ("No match, Node %s, Mode %s\n", 
+                  NS_LossyConvertUTF16toASCII(nodeName).get(),
+                  NS_LossyConvertUTF16toASCII(mode).get()));
+      }
     }
 
     if (!matchTemplate) {
         // Test for these first since a node can be both a text node
         // and a root (if it is orphaned)
         if (txXPathNodeUtils::isAttribute(aNode) ||
             txXPathNodeUtils::isText(aNode)) {
             matchTemplate = mCharactersTemplate;