ayebear / es

An easy to use, high performance, C++14 "Entity Component System" library.
MIT License
11 stars 2 forks source link

Improve Performance (PackedArray) #3

Closed ayebear closed 9 years ago

ayebear commented 9 years ago

The current implementation of PackedArray is not very fast, between 15 to 30,000 times slower than the original PackedArray, depending on the operation. The only benefit that the new version provides is unique IDs. The reason why it's slower, is because it uses two unordered_map's for keeping track of the indexes.

So, rewrite PackedArray again, so it only uses contiguous, true O(1) containers like std::vector. Use some versioning system and bit-shift IDs together, so that all IDs stay unique while still being fast. Also, don't use a free list if possible. Instead, use the holes of the index as a numeric linked list, to save memory and reduce allocations.