不要怂,就是干,撸起袖子干!

Commit 72d813b6 by Chocobozzz Committed by Sushant

perf: remove unnecessary cloneDeep calls (#11281)

1 parent 9bc6d425
...@@ -180,7 +180,7 @@ class HasMany extends Association { ...@@ -180,7 +180,7 @@ class HasMany extends Association {
instances = undefined; instances = undefined;
} }
options = Utils.cloneDeep(options); options = Object.assign({}, options);
if (this.scope) { if (this.scope) {
Object.assign(where, this.scope); Object.assign(where, this.scope);
......
...@@ -1689,7 +1689,6 @@ class Model { ...@@ -1689,7 +1689,6 @@ class Model {
this.warnOnInvalidOptions(options, Object.keys(this.rawAttributes)); this.warnOnInvalidOptions(options, Object.keys(this.rawAttributes));
const tableNames = {}; const tableNames = {};
let originalOptions;
tableNames[this.getTableName(options)] = true; tableNames[this.getTableName(options)] = true;
options = Utils.cloneDeep(options); options = Utils.cloneDeep(options);
...@@ -1751,9 +1750,8 @@ class Model { ...@@ -1751,9 +1750,8 @@ class Model {
return this.runHooks('beforeFindAfterOptions', options); return this.runHooks('beforeFindAfterOptions', options);
} }
}).then(() => { }).then(() => {
originalOptions = Utils.cloneDeep(options); const selectOptions = Object.assign({}, options, { tableNames: Object.keys(tableNames) });
options.tableNames = Object.keys(tableNames); return this.QueryInterface.select(this, this.getTableName(selectOptions), selectOptions);
return this.QueryInterface.select(this, this.getTableName(options), options);
}).tap(results => { }).tap(results => {
if (options.hooks) { if (options.hooks) {
return this.runHooks('afterFind', results, options); return this.runHooks('afterFind', results, options);
...@@ -1771,7 +1769,7 @@ class Model { ...@@ -1771,7 +1769,7 @@ class Model {
throw new sequelizeErrors.EmptyResultError(); throw new sequelizeErrors.EmptyResultError();
} }
return Model._findSeparate(results, originalOptions); return Model._findSeparate(results, options);
}); });
} }
......
...@@ -1112,10 +1112,8 @@ class QueryInterface { ...@@ -1112,10 +1112,8 @@ class QueryInterface {
); );
} }
select(model, tableName, options) { select(model, tableName, optionsArg) {
options = Utils.cloneDeep(options); const options = Object.assign({}, optionsArg, { type: QueryTypes.SELECT, model });
options.type = QueryTypes.SELECT;
options.model = model;
return this.sequelize.query( return this.sequelize.query(
this.QueryGenerator.selectQuery(tableName, options, model), this.QueryGenerator.selectQuery(tableName, options, model),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!