Skip to content

Commit

Permalink
Merge pull request #4837 from billouboq/micro-optimisations
Browse files Browse the repository at this point in the history
Micro optimisations
  • Loading branch information
vkarpov15 committed Dec 29, 2016
2 parents 90878d3 + d4bfb33 commit ecc6cfe
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/query.js
Expand Up @@ -984,7 +984,6 @@ Query.prototype._updateForExec = function() {
}
}

this._compiledUpdate = ret;
return ret;
};

Expand Down Expand Up @@ -1095,7 +1094,7 @@ Query.prototype._find = function(callback) {
if (!options.populate) {
return options.lean === true
? callback(null, docs)
: completeMany(_this.model, docs, fields, _this, null, callback);
: completeMany(_this.model, docs, fields, null, callback);
}

var pop = helpers.preparePopulationOptionsMQ(_this, options);
Expand All @@ -1104,7 +1103,7 @@ Query.prototype._find = function(callback) {
if (err) return callback(err);
return options.lean === true
? callback(null, docs)
: completeMany(_this.model, docs, fields, _this, pop, callback);
: completeMany(_this.model, docs, fields, pop, callback);
});
};

Expand Down Expand Up @@ -1219,7 +1218,7 @@ Query.prototype.merge = function(source) {
* @param {Function} callback
*/

function completeMany(model, docs, fields, self, pop, callback) {
function completeMany(model, docs, fields, pop, callback) {
var arr = [];
var count = docs.length;
var len = count;
Expand Down Expand Up @@ -1268,7 +1267,7 @@ Query.prototype._findOne = function(callback) {
if (!options.populate) {
return options.lean === true
? callback(null, doc)
: completeOne(_this.model, doc, null, projection, _this, null, callback);
: completeOne(_this.model, doc, null, projection, null, callback);
}

var pop = helpers.preparePopulationOptionsMQ(_this, options);
Expand All @@ -1279,7 +1278,7 @@ Query.prototype._findOne = function(callback) {
}
return options.lean === true
? callback(null, doc)
: completeOne(_this.model, doc, null, projection, _this, pop, callback);
: completeOne(_this.model, doc, null, projection, pop, callback);
});
});
};
Expand Down Expand Up @@ -1600,7 +1599,7 @@ Query.prototype.remove = function(cond, callback) {
* @param {Function} callback
*/

function completeOne(model, doc, res, fields, self, pop, callback) {
function completeOne(model, doc, res, fields, pop, callback) {
var opts = pop ?
{populated: pop}
: undefined;
Expand Down Expand Up @@ -1936,7 +1935,7 @@ Query.prototype._findAndModify = function(type, callback) {
if (!options.populate) {
return options.lean === true
? (opts.passRawResult ? callback(null, doc, res) : callback(null, doc))
: completeOne(_this.model, doc, res, fields, _this, null, callback);
: completeOne(_this.model, doc, res, fields, null, callback);
}

var pop = helpers.preparePopulationOptionsMQ(_this, options);
Expand All @@ -1948,7 +1947,7 @@ Query.prototype._findAndModify = function(type, callback) {

return options.lean === true
? (opts.passRawResult ? callback(null, doc, res) : callback(null, doc))
: completeOne(_this.model, doc, res, fields, _this, pop, callback);
: completeOne(_this.model, doc, res, fields, pop, callback);
});
};

Expand Down

0 comments on commit ecc6cfe

Please sign in to comment.