Skip to content

Commit

Permalink
delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jatgarg committed Mar 14, 2022
1 parent 0e80daf commit 29326db
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions packages/dds/map/src/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1545,19 +1545,11 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
if (!directory) {
return;
}
const stack: [{node: IDirectory, visited: boolean}] = [{node: directory, visited: false}];
while (stack.length > 0) {
const node = stack.pop();
assert(node !== undefined, "Sub directory should be present");
if (node.visited) {
node.node.dispose();
} else {
stack.push({node: node.node, visited: true});
const subDirectories = node.node.subdirectories();
for (const [_, subDirectory] of subDirectories) {
stack.push({node: subDirectory, visited: false});
}
}
// Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.
const subDirectories = directory.subdirectories();
for (const [_, subDirectory] of subDirectories) {
this.disposeSubDirectoryTree(subDirectory);
}
directory.dispose();
}
}

0 comments on commit 29326db

Please sign in to comment.