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

SERVER-2579: optimize append() method to use same BSONObj builder throughout process

This commit is contained in:
agirbal 2011-04-27 16:05:40 -07:00
parent 1725803c20
commit 04d364a44d
4 changed files with 13 additions and 3 deletions

View File

@ -436,6 +436,10 @@ namespace mongo {
_real->gc();
}
void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ) {
_real->append(builder, fieldName, scopeName);
}
private:
string _pool;
Scope * _real;

View File

@ -69,7 +69,7 @@ namespace mongo {
virtual int type( const char *field ) = 0;
void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName );
virtual void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName );
virtual void setElement( const char *field , const BSONElement& e ) = 0;
virtual void setNumber( const char *field , double val ) = 0;

View File

@ -47,7 +47,6 @@ namespace mongo {
BSONObj* obj = unwrapBSONObj(v8::Persistent<v8::Object>::Cast(p));
delete obj;
p.Dispose();
cout << "deleted obj" << endl;
}
static Handle<v8::Value> namedGet(Local<v8::String> name, const v8::AccessorInfo &info) {
@ -1023,7 +1022,6 @@ namespace mongo {
Persistent<v8::Object> p = Persistent<v8::Object>::New(o);
p.MakeWeak(this, weakRefCallback);
cout << "created obj" << endl;
return p;
}
@ -1155,6 +1153,13 @@ namespace mongo {
return v8::Undefined();
}
void V8Scope::append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ) {
V8_SIMPLE_HEADER
Handle<v8::String> v8name = getV8Str(scopeName);
Handle<Value> value = _global->Get( v8name );
v8ToMongoElement(builder, v8name, fieldName, value);
}
void V8Scope::v8ToMongoElement( BSONObjBuilder & b , v8::Handle<v8::String> name , const string sname , v8::Handle<v8::Value> value , int depth ) {
if ( value->IsString() ) {

View File

@ -113,6 +113,7 @@ namespace mongo {
void v8ToMongoElement( BSONObjBuilder & b , v8::Handle<v8::String> name ,
const string sname , v8::Handle<v8::Value> value , int depth = 0 );
v8::Handle<v8::Value> mongoToV8Element( const BSONElement &f );
virtual void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName );
v8::Function * getNamedCons( const char * name );
v8::Function * getObjectIdCons();