Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order of systems changes after removing a system from the engine #237

Closed
Heerdam opened this issue Aug 8, 2016 · 1 comment
Closed

order of systems changes after removing a system from the engine #237

Heerdam opened this issue Aug 8, 2016 · 1 comment
Labels

Comments

@Heerdam
Copy link

Heerdam commented Aug 8, 2016

Engine.class line 80:
systems = new Array<EntitySystem>(false, 16);

In the comments of the Array it says:

ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a memory copy.

thus, after removing a system it may or may not change order. I think in the Engine.removeSystem(EntitySystem system) a re-sorting would be in order.

@dsaltares dsaltares added the bug label Aug 9, 2016
@dsaltares
Copy link
Member

Good spot.

We could either sort the array again after every removal, which would beO(nlogn) or instantiate the systems array as sorted, which makes removals O(n).

I'd be inclined to choose the second option.

Will try to reproduce this reliable in a test case and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants