Improve iteration in MakeIterator
This commit is contained in:
parent
ddb483fff5
commit
7b23283201
1 changed files with 3 additions and 3 deletions
|
@ -11,14 +11,14 @@ export function * MakeIterator(root: IContainerModel): Generator<IContainerModel
|
|||
|
||||
yield container;
|
||||
|
||||
// if this reverse() gets costly, replace it by a simple for
|
||||
container.children.forEach((child) => {
|
||||
for (let i = container.children.length - 1; i >= 0; i--) {
|
||||
const child = container.children[i];
|
||||
if (visited.has(child)) {
|
||||
return;
|
||||
}
|
||||
visited.add(child);
|
||||
queue.push(child);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue