Skip to content

Commit 95500b6

Browse files
committed
perf(document): remove unnecessary reset logic
Re: Automattic#14897 Re: Automattic#10295
1 parent 5851261 commit 95500b6

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

lib/document.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,44 +3484,9 @@ Document.prototype.$__reset = function reset() {
34843484
// Skip for subdocuments
34853485
const subdocs = !this.$isSubdocument ? this.$getAllSubdocs() : null;
34863486
if (subdocs && subdocs.length > 0) {
3487-
const resetArrays = new Set();
34883487
for (const subdoc of subdocs) {
3489-
const fullPathWithIndexes = subdoc.$__fullPathWithIndexes();
34903488
subdoc.$__reset();
3491-
if (this.isModified(fullPathWithIndexes) || isParentInit(fullPathWithIndexes)) {
3492-
if (subdoc.$isDocumentArrayElement) {
3493-
resetArrays.add(subdoc.parentArray());
3494-
} else {
3495-
const parent = subdoc.$parent();
3496-
if (parent === this) {
3497-
this.$__.activePaths.clearPath(subdoc.$basePath);
3498-
} else if (parent != null && parent.$isSubdocument) {
3499-
// If map path underneath subdocument, may end up with a case where
3500-
// map path is modified but parent still needs to be reset. See gh-10295
3501-
parent.$__reset();
3502-
}
3503-
}
3504-
}
35053489
}
3506-
3507-
for (const array of resetArrays) {
3508-
this.$__.activePaths.clearPath(array.$path());
3509-
array[arrayAtomicsBackupSymbol] = array[arrayAtomicsSymbol];
3510-
array[arrayAtomicsSymbol] = {};
3511-
}
3512-
}
3513-
3514-
function isParentInit(path) {
3515-
path = path.indexOf('.') === -1 ? [path] : path.split('.');
3516-
let cur = '';
3517-
for (let i = 0; i < path.length; ++i) {
3518-
cur += (cur.length ? '.' : '') + path[i];
3519-
if (_this.$__.activePaths[cur] === 'init') {
3520-
return true;
3521-
}
3522-
}
3523-
3524-
return false;
35253490
}
35263491

35273492
// clear atomics

0 commit comments

Comments
 (0)