diff options
author | Andrew Morrow <acm@mongodb.com> | 2014-11-18 15:54:40 -0500 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2014-11-20 15:26:00 -0500 |
commit | d10ee8adc8265451d9fcbaae9669709618751311 (patch) | |
tree | 1edf3aab3c1d79ea9a8183eebd5cbec35b64ab51 | |
parent | e8c4f9b33b1b1b8b500e94da331a8eb9e0b9ad05 (diff) | |
download | mongo-d10ee8adc8265451d9fcbaae9669709618751311.tar.gz |
SERVER-16200 Reuse already computed field name when iterating
-rw-r--r-- | src/mongo/bson/bsonobj.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp index e0e8cef34f3..7718962a3be 100644 --- a/src/mongo/bson/bsonobj.cpp +++ b/src/mongo/bson/bsonobj.cpp @@ -657,7 +657,11 @@ namespace mongo { BSONObjIterator i(*this); while ( i.more() ) { BSONElement e = i.next(); - if ( name == e.fieldName() ) + // We know that e has a cached field length since BSONObjIterator::next internally + // called BSONElement::size on the BSONElement that it returned, so it is more + // efficient to re-use that information by obtaining the field name as a + // StringData, which will be pre-populated with the cached length. + if ( name == e.fieldNameStringData() ) return e; } return BSONElement(); |