diff options
author | Mathias Stearn <mathias@10gen.com> | 2012-11-15 13:59:20 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2012-11-15 13:59:38 -0500 |
commit | fa283ee1d6a4900497753e807a678905d029c540 (patch) | |
tree | 6d9808caa7078ed464dc0ad69c039b082e4e181f | |
parent | f3121bdcd1e330e49092287faa6b70898c973eca (diff) | |
download | mongo-fa283ee1d6a4900497753e807a678905d029c540.tar.gz |
Make Projection use StringMap
-rw-r--r-- | src/mongo/db/projection.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/projection.h | 5 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/mongo/db/projection.cpp b/src/mongo/db/projection.cpp index 21d95000418..5e2f204de56 100644 --- a/src/mongo/db/projection.cpp +++ b/src/mongo/db/projection.cpp @@ -75,9 +75,8 @@ namespace mongo { // initialize new Matcher object(s) - _matchers.insert( make_pair( - mongoutils::str::before( e.fieldName(), '.' ), - shared_ptr<Matcher>( new Matcher( e.wrap(), true ) ) ) ); + _matchers[mongoutils::str::before(e.fieldName(), '.').c_str()] + = boost::make_shared<Matcher>(e.wrap(), true); add( e.fieldName(), true ); } else { @@ -127,9 +126,9 @@ namespace mongo { const string subfield = field.substr(0,dot); const string rest = (dot == string::npos ? "" : field.substr(dot+1,string::npos)); - boost::shared_ptr<Projection>& fm = _fields[subfield]; + boost::shared_ptr<Projection>& fm = _fields[subfield.c_str()]; if (!fm) - fm.reset(new Projection()); + fm = boost::make_shared<Projection>(); fm->add(rest, include); } @@ -147,9 +146,9 @@ namespace mongo { const string subfield = field.substr(0,dot); const string rest = (dot == string::npos ? "" : field.substr(dot+1,string::npos)); - boost::shared_ptr<Projection>& fm = _fields[subfield]; + boost::shared_ptr<Projection>& fm = _fields[subfield.c_str()]; if (!fm) - fm.reset(new Projection()); + fm = boost::make_shared<Projection>(); fm->add(rest, skip, limit); } diff --git a/src/mongo/db/projection.h b/src/mongo/db/projection.h index c4844f7a146..418c6fe5ca8 100644 --- a/src/mongo/db/projection.h +++ b/src/mongo/db/projection.h @@ -18,6 +18,7 @@ #pragma once #include "mongo/pch.h" +#include "mongo/util/string_map.h" #include "jsobj.h" namespace mongo { @@ -140,7 +141,7 @@ namespace mongo { bool _special; // true if this level can't be skipped or included without recursing //TODO: benchmark vector<pair> vs map - typedef map<string, boost::shared_ptr<Projection> > FieldMap; + typedef StringMap<boost::shared_ptr<Projection> > FieldMap; FieldMap _fields; BSONObj _source; bool _includeID; @@ -150,7 +151,7 @@ namespace mongo { int _limit; // used for $elemMatch and positional operator ($) - typedef map<string, shared_ptr<Matcher> > Matchers; + typedef StringMap<boost::shared_ptr<Matcher> > Matchers; Matchers _matchers; ArrayOpType _arrayOpType; |