Skip to content

Add Commands::insert_batch for faster component modification #2693

@alice-i-cecile

Description

@alice-i-cecile

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 and remove_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-PerformanceA change motivated by improving speed, memory usage or compile timesD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions