Skip to content

Commit

Permalink
perf(document): avoid cloning options using spread operator for perf …
Browse files Browse the repository at this point in the history
…reasons

Re: #14394
  • Loading branch information
vkarpov15 committed May 4, 2024
1 parent 175da6b commit e910cb7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -3855,7 +3855,11 @@ Document.prototype.$toObject = function(options, json) {
}

// merge default options with input options.
options = { ...defaultOptions, ...options };
for (const key of Object.keys(defaultOptions)) {
if (options[key] == null) {
options[key] = defaultOptions[key];
}
}
options._isNested = true;
options.json = json;
options.minimize = _minimize;
Expand Down

0 comments on commit e910cb7

Please sign in to comment.