Permalink
Browse files

Merge branch 'master' of github.com:mongodb/mongo

  • Loading branch information...
2 parents a22cc7e + 39b45bf commit bad51fbd549f03c84ebe6bab124f61105a9207ee Alberto Lerner committed Oct 27, 2010
Showing with 16 additions and 28 deletions.
  1. +10 −1 bson/bsoninlines.h
  2. +4 −9 bson/bsonobj.h
  3. +2 −18 db/btree.cpp
View
@@ -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);
View
@@ -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 */
View
@@ -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 );
}

0 comments on commit bad51fb

Please sign in to comment.