0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Write new num value just once

This commit is contained in:
Aaron 2009-03-25 17:12:27 -04:00
parent 547a455b5b
commit 2506307e43

View File

@ -347,9 +347,8 @@ namespace mongo {
const Mod& m = *i;
BSONElement e = obj.getFieldDotted(m.fieldName);
if ( m.op == Mod::INC ) {
BSONElementManipulator( e ).setNumber( e.number() + m.getn() );
BSONElementManipulator( m.elt ).setNumber( e.number() );
m.setn( e.number() );
m.setn( e.number() + m.getn() );
BSONElementManipulator( e ).setNumber( m.getn() );
} else {
if ( e.isNumber() && m.elt.isNumber() )
BSONElementManipulator( e ).setNumber( m.getn() );
@ -403,8 +402,7 @@ namespace mongo {
if ( cmp == 0 ) {
BSONElement e = p->second;
if ( m->op == Mod::INC ) {
BSONElementManipulator( m->elt ).setNumber( e.number() + m->getn() );
m->setn( m->elt.number() );
m->setn( m->getn() + e.number() );
b2.appendAs( m->elt, m->fieldName );
} else if ( m->op == Mod::SET ) {
b2.appendAs( m->elt, m->fieldName );