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

Improve Performance (Component types with type_index) #1

Open
ayebear opened this issue Jun 3, 2015 · 0 comments
Open

Improve Performance (Component types with type_index) #1

ayebear opened this issue Jun 3, 2015 · 0 comments

Comments

@ayebear
Copy link
Owner

ayebear commented Jun 3, 2015

Remove the use of type_index with unordered_map for components. Even though unordered_map has an amortized constant lookup/insertion time, it's still a few orders of magnitude slower than a raw vector.

Since components won't need to be un-registered, implement a "family ID" setup for Component types that starts at 0. Then, use a vector where the index is the ID, in these situations:

  • In the ComponentPool, to store multiple ComponentArray instances
  • In EntityData (inside of Core) to store the component set for each Entity
    • The component set should be resized to the total number of component types, so adding new components won't trigger reallocations.
    • While the component sets are going to be initially larger, they will still be relatively small. It's worth it for the performance improvement and consistency. Even unordered_map takes up extra memory than the number of elements inside it anyway.
@ayebear ayebear changed the title Improve Performance (Components) Improve Performance (Component types with type_index) Jun 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant