From 32d227bc04096ddd3bc09bdaab194c5cb430af6a Mon Sep 17 00:00:00 2001 From: "Christopher L. Conway" Date: Thu, 15 Apr 2010 16:56:06 +0000 Subject: [PATCH] Moving debug output in ~ContextObj under a conditional. Should fix most of the slowdown from r413. --- src/context/context.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/context/context.cpp b/src/context/context.cpp index d371dc39a..ca6564cf5 100644 --- a/src/context/context.cpp +++ b/src/context/context.cpp @@ -227,9 +227,13 @@ ContextObj* ContextObj::restoreAndContinue() throw(AssertionException) { void ContextObj::destroy() throw(AssertionException) { - Debug("context") << "before destroy " << this - << " (level " << getLevel() << "):" << std::endl - << *getContext() << std::endl; + if( Debug.isOn("context") ) { + /* Context can be big and complicated, so we only want to process this output + * if we're really going to use it. (Same goes below.) + */ + Debug("context") << "before destroy " << this << " (level " << getLevel() + << "):" << std::endl << *getContext() << std::endl; + } for(;;) { // If valgrind reports invalid writes on the next few lines, // here's a hint: make sure all classes derived from ContextObj in @@ -242,14 +246,18 @@ void ContextObj::destroy() throw(AssertionException) { if(d_pContextObjRestore == NULL) { break; } - Debug("context") << "in destroy " << this << ", restore object is " - << d_pContextObjRestore << " at level " - << d_pContextObjRestore->getLevel() << ":" << std::endl - << *getContext() << std::endl; + if( Debug.isOn("context") ) { + Debug("context") << "in destroy " << this << ", restore object is " + << d_pContextObjRestore << " at level " + << d_pContextObjRestore->getLevel() << ":" << std::endl + << *getContext() << std::endl; + } restoreAndContinue(); } - Debug("context") << "after destroy " << this << ":" << std::endl - << *getContext() << std::endl; + if( Debug.isOn("context") ) { + Debug("context") << "after destroy " << this << ":" << std::endl + << *getContext() << std::endl; + } } -- 2.30.2