fast path for mongodb batches (otherwise it's O(n^2) memory, which gets ugly fast)

This commit is contained in:
Ben Lubar
2016-02-29 14:05:17 -06:00
parent fb4f1e1315
commit df8c1abf7d
2 changed files with 43 additions and 2 deletions

View File

@@ -23,6 +23,11 @@ var async = require('async'),
return callback(new Error('[[error:process-not-a-function]]'));
}
// use the fast path if possible
if (db.processSortedSet && typeof options.doneIf !== 'function' && !utils.isNumber(options.alwaysStartAt)) {
return db.processSortedSet(setKey, process, options.batch || DEFAULT_BATCH_SIZE, callback);
}
// custom done condition
options.doneIf = typeof options.doneIf === 'function' ? options.doneIf : function(){};
@@ -58,4 +63,4 @@ var async = require('async'),
);
};
}(exports));
}(exports));