`preallocate = N` setting for `#[derive(Component)]`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
This fills the role of [`Vec::with_capacity()`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.with_capacity), but for a component's storage table.
## What solution would you like?
This parameter would cause the backing storage table of a component to start with enough reserved capacity for (at least) N instances of the component.
## What alternative(s) have you considered?
I do not know of any alternative way of doing this - especially as [`bevy_ecs::storage::Table`](https://docs.rs/bevy_ecs/latest/bevy_ecs/storage/struct.Table.html) does not include any way of affecting the capacity of a table.
## Additional context
`bevy_ecs::storage::Table` already exposes the allocated capacity of a table via [`.entity_capacity()`](https://docs.rs/bevy_ecs/latest/bevy_ecs/storage/struct.Table.html#method.entity_capacity). In turn, this can be used in a manner similar to [`Vec.capacity()`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.capacity) - though I struggle to see how it'd be useful without any meaningful method of affecting the capacity (aside from, of course, attaching the component to more entities).
Contributor guide
Assessment
This issue has not been assessed yet.