Bug 1163192 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj

Check that logging is enabled before performing potentially expensive
operations.
This commit is contained in:
Eric Rahm 2015-05-11 13:56:59 -07:00
parent 698f689e80
commit 17c9cb1b3e

View File

@ -157,27 +157,29 @@ txStylesheet::findTemplate(const txXPathNode& aNode,
}
}
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) {