diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-07-29 11:45:51 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-07-29 14:40:31 -0400 |
commit | 9db572c59ee80375e0c4b6547a0a883bd175036b (patch) | |
tree | 702aa0608f1054b43ee6cd93e6d427d086e83fec /src/mongo/db/matcher/match_details.cpp | |
parent | 47edf5d5590798986ea721e06a3595cad381f196 (diff) | |
download | mongo-9db572c59ee80375e0c4b6547a0a883bd175036b.tar.gz |
some MatchDetails peformance improvements and move more impl to .cpp
Diffstat (limited to 'src/mongo/db/matcher/match_details.cpp')
-rw-r--r-- | src/mongo/db/matcher/match_details.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/mongo/db/matcher/match_details.cpp b/src/mongo/db/matcher/match_details.cpp index 85938c7a849..087f8c14cfe 100644 --- a/src/mongo/db/matcher/match_details.cpp +++ b/src/mongo/db/matcher/match_details.cpp @@ -16,28 +16,44 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "mongo/pch.h" - #include "mongo/db/matcher/match_details.h" +#include <sstream> + +#include "mongo/util/assert_util.h" + namespace mongo { MatchDetails::MatchDetails() : - _elemMatchKeyRequested() { + _elemMatchKeyRequested() { resetOutput(); } void MatchDetails::resetOutput() { _loadedRecord = false; - _elemMatchKeyFound = false; - _elemMatchKey = ""; + _elemMatchKey.reset(); + } + + bool MatchDetails::hasElemMatchKey() const { + return _elemMatchKey.get(); + } + + std::string MatchDetails::elemMatchKey() const { + verify( hasElemMatchKey() ); + return *(_elemMatchKey.get()); + } + + void MatchDetails::setElemMatchKey( const std::string &elemMatchKey ) { + if ( _elemMatchKeyRequested ) { + _elemMatchKey.reset( new std::string( elemMatchKey ) ); + } } string MatchDetails::toString() const { - stringstream ss; + std::stringstream ss; ss << "loadedRecord: " << _loadedRecord << " "; ss << "elemMatchKeyRequested: " << _elemMatchKeyRequested << " "; - ss << "elemMatchKey: " << ( _elemMatchKeyFound ? _elemMatchKey : "NONE" ) << " "; + ss << "elemMatchKey: " << ( _elemMatchKey ? _elemMatchKey->c_str() : "NONE" ) << " "; return ss.str(); } |