Skip to content

Commit

Permalink
optimise destroy remove children
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed May 1, 2024
1 parent 1995851 commit b4f363b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/scene/container/Container.ts
Expand Up @@ -1328,6 +1328,9 @@ export class Container<C extends ContainerChild = ContainerChild> extends EventE
if (this.destroyed) return;
this.destroyed = true;

// remove children is faster than removeChild..
const oldChildren = this.removeChildren(0, this.children.length);

this.removeFromParent();
this.parent = null;
this._mask = null;
Expand All @@ -1344,8 +1347,6 @@ export class Container<C extends ContainerChild = ContainerChild> extends EventE

const destroyChildren = typeof options === 'boolean' ? options : options?.children;

const oldChildren = this.removeChildren(0, this.children.length);

if (destroyChildren)
{
for (let i = 0; i < oldChildren.length; ++i)
Expand Down

0 comments on commit b4f363b

Please sign in to comment.