Skip to content

Commit

Permalink
refactor: use for loop replace spread to fix stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zzuu666 committed Dec 9, 2024
1 parent d7ae8b5 commit 13a0754
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dev/lib/edit-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ export class EditMap {
events.length = this.map[index][0]
}

vecs.push([...events])
vecs.push(events.slice())
events.length = 0

let slice = vecs.pop()

while (slice) {
events.push(...slice)
// NOTE: do not use spread operator here, it will cause a stack overflow.
for (let i = 0; i < slice.length; i++) {
events.push(slice[i])
}
slice = vecs.pop()
}

Expand Down

0 comments on commit 13a0754

Please sign in to comment.