Skip to content

Commit

Permalink
perf(document): fix build, avoid unnecessary Object.keys() re: #13191
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Apr 16, 2023
1 parent 4f22223 commit 51b8982
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -2221,9 +2221,8 @@ Document.prototype.isModified = function(paths, modifiedPaths) {
paths = paths.indexOf(' ') === -1 ? [paths] : paths.split(' ');
}

const directModifiedPathsObj = this.$__.activePaths.getStatePaths('modify');
const directModifiedPaths = Object.keys(directModifiedPathsObj);
if (directModifiedPaths.length === 0) {
const directModifiedPathsObj = this.$__.activePaths.states.modify;
if (directModifiedPathsObj == null) {
return false;
}
for (const path of paths) {
Expand All @@ -2237,6 +2236,7 @@ Document.prototype.isModified = function(paths, modifiedPaths) {
return !!~modified.indexOf(path);
});

const directModifiedPaths = Object.keys(directModifiedPathsObj);
return isModifiedChild || paths.some(function(path) {
return directModifiedPaths.some(function(mod) {
return mod === path || path.startsWith(mod + '.');
Expand Down Expand Up @@ -3324,10 +3324,7 @@ Document.prototype.$__reset = function reset() {
let _this = this;

// Skip for subdocuments
if (this.$isDocumentArrayElement || this.$isSingleNested) {
return this;
}
const subdocs = this.$getAllSubdocs();
const subdocs = this.$parent() === this ? this.$getAllSubdocs() : [];
const resetArrays = new Set();
for (const subdoc of subdocs) {
const fullPathWithIndexes = subdoc.$__fullPathWithIndexes();
Expand Down

0 comments on commit 51b8982

Please sign in to comment.