diff options
Diffstat (limited to 'src/mongo/db/matcher/path_internal.cpp')
-rw-r--r-- | src/mongo/db/matcher/path_internal.cpp | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/mongo/db/matcher/path_internal.cpp b/src/mongo/db/matcher/path_internal.cpp index d8ccfe0ea9b..31b850e6834 100644 --- a/src/mongo/db/matcher/path_internal.cpp +++ b/src/mongo/db/matcher/path_internal.cpp @@ -32,31 +32,27 @@ namespace mongo { - bool isAllDigits( StringData str ) { - for ( unsigned i = 0; i < str.size(); i++ ) { - if ( !isdigit( str[i] ) ) - return false; - } - return true; +bool isAllDigits(StringData str) { + for (unsigned i = 0; i < str.size(); i++) { + if (!isdigit(str[i])) + return false; } + return true; +} - BSONElement getFieldDottedOrArray( const BSONObj& doc, - const FieldRef& path, - size_t* idxPath ) { - if ( path.numParts() == 0 ) - return doc.getField( "" ); - - BSONElement res; - - BSONObj curr = doc; - bool stop = false; - size_t partNum = 0; - while ( partNum < path.numParts() && !stop ) { +BSONElement getFieldDottedOrArray(const BSONObj& doc, const FieldRef& path, size_t* idxPath) { + if (path.numParts() == 0) + return doc.getField(""); - res = curr.getField( path.getPart( partNum ) ); + BSONElement res; - switch ( res.type() ) { + BSONObj curr = doc; + bool stop = false; + size_t partNum = 0; + while (partNum < path.numParts() && !stop) { + res = curr.getField(path.getPart(partNum)); + switch (res.type()) { case EOO: stop = true; break; @@ -71,17 +67,16 @@ namespace mongo { break; default: - if ( partNum+1 < path.numParts() ) { + if (partNum + 1 < path.numParts()) { res = BSONElement(); } stop = true; - - } } - - *idxPath = partNum; - return res; } + *idxPath = partNum; + return res; +} + } // namespace mongo |