We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2480cf0 commit 4dcd3d4Copy full SHA for 4dcd3d4
1 file changed
src/utils/lru.ts
@@ -141,11 +141,18 @@ export class LRU {
141
}
142
143
disposeDescendants(node: Node): void {
144
+ // Collect all the nodes which are to be disposed and removed.
145
+ const nodesToDispose: Node[] = [];
146
node.traverse(n => {
147
if (n.loaded) {
- n.dispose();
- this.remove(n);
148
+ nodesToDispose.push(n);
149
150
});
151
+
152
+ // Dispose of all the nodes in one go.
153
+ for (const n of nodesToDispose) {
154
+ n.dispose();
155
+ this.remove(n);
156
+ }
157
158
0 commit comments