summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-01-31 00:12:04 -0500
committerEliot Horowitz <eliot@10gen.com>2011-01-31 00:12:04 -0500
commita5afcff3247eee5baba8be0c7afd7051fc1f73dd (patch)
tree1effda878fffb6889b72709aac548e858c9d098b /db
parent55637a2881455cde1483c7f4d9fdf0ee36ea4328 (diff)
downloadmongo-a5afcff3247eee5baba8be0c7afd7051fc1f73dd.tar.gz
make getFieldDottedOrArray 2x faster
Diffstat (limited to 'db')
-rw-r--r--db/jsobj.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/db/jsobj.cpp b/db/jsobj.cpp
index e392385827f..25ab8a84dbb 100644
--- a/db/jsobj.cpp
+++ b/db/jsobj.cpp
@@ -741,16 +741,18 @@ namespace mongo {
BSONElement BSONObj::getFieldDottedOrArray(const char *&name) const {
const char *p = strchr(name, '.');
- string left;
+
+ BSONElement sub;
+
if ( p ) {
- left = string(name, p-name);
+ sub = getField( string(name, p-name) );
name = p + 1;
}
else {
- left = string(name);
+ sub = getField( name );
name = name + strlen(name);
}
- BSONElement sub = getField(left.c_str());
+
if ( sub.eoo() )
return nullElement;
else if ( sub.type() == Array || name[0] == '\0')