Add index key for entities to improve use case performance
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 215
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Add API can set key for entities, and use the key fast find entities
"specs::prelude::WorldExt" add function
fn find_entities(&self, key: T) -> Read
and add
fn create_entity_by_key(&mut self, key: T) -> EntityBuilder
## Motivation
In open source game "veloren"
I usually see the code.
```rust
let entity_opt = (&ecs.entities(), &ecs.read_storage::())
.join()
.find(|(_, player)| player.alias == player_alias)
.map(|(entity, _)| entity);
```
Basically, any query from player will loop all entities to find alias equal query name.
If ecs has 10000 players. the design include performance bottleneck.
## Drawbacks
* Is it a breaking change?
no.
* Can it impact performance, learnability, etc?
to improve performance for search specific entitie
## Unresolved questions
I just learn this project. I think author group will give me a best solution.
---
Please indicate here if you'd like to work on this ticket once it's been approved. Feel free to delete this section if not.
Contributor guide
Assessment
This issue has not been assessed yet.