diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-01-31 00:12:04 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-01-31 00:12:04 -0500 |
commit | a5afcff3247eee5baba8be0c7afd7051fc1f73dd (patch) | |
tree | 1effda878fffb6889b72709aac548e858c9d098b /db | |
parent | 55637a2881455cde1483c7f4d9fdf0ee36ea4328 (diff) | |
download | mongo-a5afcff3247eee5baba8be0c7afd7051fc1f73dd.tar.gz |
make getFieldDottedOrArray 2x faster
Diffstat (limited to 'db')
-rw-r--r-- | db/jsobj.cpp | 10 |
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') |