Skip to content

Commit

Permalink
perf(document): add fast path for applying non-nested virtuals to JSON
Browse files Browse the repository at this point in the history
Re: #14394
  • Loading branch information
vkarpov15 committed Apr 27, 2024
1 parent e91fcf4 commit 8ead266
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/document.js
Expand Up @@ -4130,6 +4130,14 @@ function applyVirtuals(self, json, options, toObjectOptions) {
}
assignPath = path.substring(options.path.length + 1);
}
if (assignPath.indexOf('.') === -1 && assignPath === path) {
v = clone(self.get(path, options ? { ...options, noDottedPath: true } : { noDottedPath: true }));
if (v === void 0) {
continue;
}
json[assignPath] = v;
continue;
}
const parts = assignPath.split('.');
v = clone(self.get(path), options);
if (v === void 0) {
Expand Down

0 comments on commit 8ead266

Please sign in to comment.