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;
|
yield container;
|
||||||
|
|
||||||
// if this reverse() gets costly, replace it by a simple for
|
for (let i = container.children.length - 1; i >= 0; i--) {
|
||||||
container.children.forEach((child) => {
|
const child = container.children[i];
|
||||||
if (visited.has(child)) {
|
if (visited.has(child)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
visited.add(child);
|
visited.add(child);
|
||||||
queue.push(child);
|
queue.push(child);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue