Skip to content

Commit

Permalink
move ClientCursor to stack SERVER-494
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Dec 17, 2009
1 parent 4771ba6 commit e7eb18f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions db/query.cpp
Expand Up @@ -139,36 +139,36 @@ namespace mongo {

KeyValJSMatcher matcher(pattern, creal->indexKeyPattern());

ClientCursor cc;
cc.c = creal;
cc.ns = ns;
cc.liveForever();
cc.setDoingDeletes( true );
auto_ptr<ClientCursor> cc;
cc.reset( new ClientCursor() );
cc->c = creal;
cc->ns = ns;
cc->liveForever();
cc->setDoingDeletes( true );
do {

if ( nDeleted % 100 == 99 ){
cc.updateLocation();
cc.setDoingDeletes( false );
cc->updateLocation();
cc->setDoingDeletes( false );
dbtemprelease unlock;
}
cc.setDoingDeletes( true );
cc->setDoingDeletes( true );

DiskLoc rloc = cc.c->currLoc();
BSONObj key = cc.c->currKey();
DiskLoc rloc = cc->c->currLoc();
BSONObj key = cc->c->currKey();

cc.c->advance();
cc.updateLocation();
cc->c->advance();

if ( ! matcher.matches( key , rloc ) )
continue;

assert( !cc.c->getsetdup(rloc) ); // can't be a dup, we deleted it!
assert( !cc->c->getsetdup(rloc) ); // can't be a dup, we deleted it!

if ( !justOne ) {
/* NOTE: this is SLOW. this is not good, noteLocation() was designed to be called across getMore
blocks. here we might call millions of times which would be bad.
*/
cc.c->noteLocation();
cc->c->noteLocation();
}

if ( logop ) {
Expand All @@ -187,9 +187,9 @@ namespace mongo {
nDeleted++;
if ( justOne )
break;
cc.c->checkLocation();
cc->c->checkLocation();

} while ( cc.c->ok() );
} while ( cc->c->ok() );

return nDeleted;
}
Expand Down

0 comments on commit e7eb18f

Please sign in to comment.