Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
perf(document): add fast path for applying non-nested virtuals to JSON
Re: #14394
  • Loading branch information
vkarpov15 committed Apr 27, 2024
commit 8ead26657e49afbd1bf9ff9009d6c71f97c37c7e
8 changes: 8 additions & 0 deletions lib/document.js
Original file line number Diff line number Diff line change
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