Add Commands::insert_batch for faster component modification #2693
Labels
A-ECS
Entities, components, systems, and events
C-Performance
A change motivated by improving speed, memory usage or compile times
D-Straightforward
Simple bug fixes and API improvements, docs, test and examples
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
X-Uncontroversial
This work is generally agreed upon
What problem does this solve or what need does it fill?
Inserting components one at a time is slow.
What solution would you like?
Add
Commands::insert_batch
andremove_batch
to modify components en-masse in a more efficient way.As discussed in #3227 (comment), this should be a safe, typed equivalent to
EntityWorldMut::insert_by_ids
that's exposed to commands.I think that a builder API that iteratively modifies the underlying
Command
struct is probably the correct design.What alternative(s) have you considered?
We could use
insert_or_spawn_batch
for the insertion case, but that does not fail in the desired ways at all.Additional context
Follows up on the work from #2673, which added
insert_or_spawn_batch
. Ideally we can use the same strategy for this work, and perform similar benchmarks.The text was updated successfully, but these errors were encountered: