amethyst / specs

Specs - Parallel ECS
https://amethyst.github.io/specs/
Apache License 2.0
2.49k stars 219 forks source link

In MarkerAllocator Trait retrieve_entity_internal could take id by reference #728

Open Dollab opened 3 years ago

Dollab commented 3 years ago

Description

Currently the method retrieve_entity_internal of the MarkerAllocator Trait moves the id of the identifier instead of taking it by reference. This is not a concern for small identifier such as i32/i64 but forces unnecessary allocations when using larger structures (such as a string for example). The implementation of the method will usually be some kind of value get from a map which would only need a reference itself. Therefore the move seems suboptimal here. I may be missing something here but I really do not see the advantage of moving the id instead of taking a reference.

Motivation

When deserializing an important amount of entities (>100k) marked with a string identifier (for example a uuid) the string has to be cloned for each entity which degrades the performance.

Drawbacks

Unresolved questions


I'll happily provide a PR if this change was approved.