diff options
author | Aaron <aaron@10gen.com> | 2012-02-26 19:17:35 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2012-02-29 17:42:25 -0800 |
commit | e0b685a829cc2351ad682c86c61f5becdb359c63 (patch) | |
tree | f89a5b5da211d1d2393af5cd8a44c077fad7f383 /src/mongo/db/explain.cpp | |
parent | 28122356ec72347f3414bd204d9bf83d15696e60 (diff) | |
download | mongo-e0b685a829cc2351ad682c86c61f5becdb359c63.tar.gz |
SERVER-4150 simplify logic for picking a plan to report at top of explain
Diffstat (limited to 'src/mongo/db/explain.cpp')
-rw-r--r-- | src/mongo/db/explain.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mongo/db/explain.cpp b/src/mongo/db/explain.cpp index 89a7f0bef5d..ecfa182f85e 100644 --- a/src/mongo/db/explain.cpp +++ b/src/mongo/db/explain.cpp @@ -170,22 +170,18 @@ namespace mongo { } } // Return a plan with the highest match count. - // TODO simplify - long long maxN = 0; + long long maxN = -1; + shared_ptr<const ExplainPlanInfo> ret; for( list<shared_ptr<const ExplainPlanInfo> >::const_iterator i = _plans.begin(); i != _plans.end(); ++i ) { - if ( (*i)->n() > maxN ) { - maxN = (*i)->n(); + long long n = ( *i )->n(); + if ( n > maxN ) { + maxN = n; + ret = *i; } } - for( list<shared_ptr<const ExplainPlanInfo> >::const_iterator i = _plans.begin(); - i != _plans.end(); ++i ) { - if ( (*i)->n() == maxN ) { - return **i; - } - } - verify( 16076, false ); - return *(new ExplainPlanInfo()); + verify( 16076, ret ); + return *ret; } void ExplainQueryInfo::noteIterate( bool match, bool loadedObject, bool chunkSkip ) { |