Add index key for entities to improve use case performance
- Lingua principale
- Rust
- Stelle
- 2.6k
- Fork
- 215
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## 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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.