diff options
author | Alberto Lerner <alerner@10gen.com> | 2010-10-27 12:19:33 -0400 |
---|---|---|
committer | Alberto Lerner <alerner@10gen.com> | 2010-10-27 12:19:33 -0400 |
commit | bad51fbd549f03c84ebe6bab124f61105a9207ee (patch) | |
tree | 92be8d7183b88a1b54465fe544eecbcb8242b51b | |
parent | a22cc7e48d666b0c8b5cdcaa4321addbd5f08653 (diff) | |
parent | 39b45bf3992e76f29edeb5c3ed1919515f8abf97 (diff) | |
download | mongo-bad51fbd549f03c84ebe6bab124f61105a9207ee.tar.gz |
Merge branch 'master' of github.com:mongodb/mongo
-rw-r--r-- | bson/bsoninlines.h | 11 | ||||
-rw-r--r-- | bson/bsonobj.h | 13 | ||||
-rw-r--r-- | db/btree.cpp | 20 |
3 files changed, 16 insertions, 28 deletions
diff --git a/bson/bsoninlines.h b/bson/bsoninlines.h index f3d52765db1..1142d08e8e3 100644 --- a/bson/bsoninlines.h +++ b/bson/bsoninlines.h @@ -48,12 +48,21 @@ namespace mongo { return BSONObj( value() + 4 + 4 + strSizeWNull ); } - inline BSONObj BSONObj::copy() const { + /* the idea with NOINLINE_DECL here is to keep this from inlining in the + getOwned() method. the presumption being that is better. + */ + inline NOINLINE_DECL BSONObj BSONObj::copy() const { char *p = (char*) malloc(objsize()); memcpy(p, objdata(), objsize()); return BSONObj(p, true); } + inline BSONObj BSONObj::getOwned() const { + if ( isOwned() ) + return *this; + return copy(); + } + // wrap this element up as a singleton object. inline BSONObj BSONElement::wrap() const { BSONObjBuilder b(size()+6); diff --git a/bson/bsonobj.h b/bson/bsonobj.h index 1c75f240bc5..68069ddf114 100644 --- a/bson/bsonobj.h +++ b/bson/bsonobj.h @@ -251,9 +251,7 @@ namespace mongo { } /** @return first field of the object */ - BSONElement firstElement() const { - return BSONElement(objdata() + 4); - } + BSONElement firstElement() const { return BSONElement(objdata() + 4); } /** @return true if field exists in the object */ bool hasElement(const char *name) const; @@ -265,15 +263,12 @@ namespace mongo { */ bool getObjectID(BSONElement& e) const; - /** makes a copy of the object. */ + /** @return a new full copy of the object. */ BSONObj copy() const; /* make sure the data buffer is under the control of this BSONObj and not a remote buffer */ - BSONObj getOwned() const{ - if ( !isOwned() ) - return copy(); - return *this; - } + BSONObj getOwned() const; + bool isOwned() const { return _holder.get() != 0; } /** @return A hash code for the object */ diff --git a/db/btree.cpp b/db/btree.cpp index 64ab0877797..93cf104b5c4 100644 --- a/db/btree.cpp +++ b/db/btree.cpp @@ -597,24 +597,8 @@ namespace mongo { assert( !isHead() ); BtreeBucket *p = parent.btreemod(); - if ( p->nextChild == thisLoc ) { - p->nextChild.Null(); - } - else { - for ( int i = 0; i < p->n; i++ ) { - if ( p->k(i).prevChildBucket == thisLoc ) { - p->k(i).prevChildBucket.Null(); - goto found; - } - } - out() << "ERROR: can't find ref to deleted bucket.\n"; - out() << "To delete:\n"; - dump(); - out() << "Parent:\n"; - p->dump(); - assert(false); - } -found: + int parentIdx = indexInParent( thisLoc ); + p->child( parentIdx ).Null(); deallocBucket( thisLoc, id ); } |