From 69035fca654edfa038e17d1c4543206c48708f6b Mon Sep 17 00:00:00 2001 From: Shaun Verch Date: Mon, 15 Oct 2012 16:42:39 -0700 Subject: SERVER-7231 Construct log helper variables only when they will be logged --- src/mongo/client/parallel.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/mongo/client/parallel.cpp b/src/mongo/client/parallel.cpp index d8f9726a45a..8bd387c1574 100644 --- a/src/mongo/client/parallel.cpp +++ b/src/mongo/client/parallel.cpp @@ -774,8 +774,14 @@ namespace mongo { ShardPtr primary; string prefix; - if( _totalTries > 0 ) prefix = str::stream() << "retrying (" << _totalTries << " tries)"; - else prefix = "creating"; + if (MONGO_unlikely(logLevel >= pc)) { + if( _totalTries > 0 ) { + prefix = str::stream() << "retrying (" << _totalTries << " tries)"; + } + else { + prefix = "creating"; + } + } LOG( pc ) << prefix << " pcursor over " << _qSpec << " and " << _cInfo << endl; set todoStorage; @@ -790,8 +796,16 @@ namespace mongo { // Try to get either the chunk manager or the primary shard config->getChunkManagerOrPrimary( ns, manager, primary ); - if( manager ) vinfo = ( str::stream() << "[" << manager->getns() << " @ " << manager->getVersion().toString() << "]" ); - else vinfo = (str::stream() << "[unsharded @ " << primary->toString() << "]" ); + if (MONGO_unlikely(logLevel >= pc)) { + if (manager) { + vinfo = str::stream() << "[" << manager->getns() << " @ " + << manager->getVersion().toString() << "]"; + } + else { + vinfo = str::stream() << "[unsharded @ " + << primary->toString() << "]"; + } + } if( manager ) manager->getShardsForQuery( todo, specialFilter ? _cInfo.cmdFilter : _qSpec.filter() ); else if( primary ) todo.insert( *primary ); @@ -810,8 +824,9 @@ namespace mongo { // Don't use version to get shards here todo = _qShards; - vinfo = str::stream() << "[" << _qShards.size() << " shards specified]"; - + if (MONGO_unlikely(logLevel >= pc)) { + vinfo = str::stream() << "[" << _qShards.size() << " shards specified]"; + } } verify( todo.size() ); -- cgit v1.2.1