fix queue and use a unsafe but performant checker

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 80172126cf
commit 4fc632b40e

View File

@@ -917,7 +917,7 @@ export class Replayer {
next = mirror.getNode(mutation.nextId) as Node; next = mirror.getNode(mutation.nextId) as Node;
} }
if (nextNotInDOM(mutation)) { if (nextNotInDOM(mutation)) {
queue.push(mutation); return queue.push(mutation);
} }
const target = buildNodeWithSN( const target = buildNodeWithSN(
@@ -962,12 +962,19 @@ export class Replayer {
appendNode(mutation); appendNode(mutation);
}); });
let startTime = Date.now();
while (queue.length) { while (queue.length) {
if ( /**
queue.every( * Looks like this check is killing the performance
(m) => !Boolean(mirror.getNode(m.parentId)) || nextNotInDOM(m), */
) // if (
) { // queue.every(
// (m) => !Boolean(mirror.getNode(m.parentId)) || nextNotInDOM(m),
// )
// ) {
// return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id));
// }
if (Date.now() - startTime > 5000) {
return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id)); return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id));
} }
const mutation = queue.shift()!; const mutation = queue.shift()!;