Skip to content

Conversation

JaySpruce
Copy link
Member

Objective

world/entity_ref.rs is the biggest single source file in Bevy at ~6800 lines. It can be a bit hard to navigate.

Solution

Rename the entity_ref module to entity_access and split it into 8 files:

  • mod.rs: Re-exports and testing, ~1600 lines
  • entity_ref.rs: EntityRef type, ~340 lines
  • entity_mut.rs: EntityMut type, ~760 lines
  • world_mut.rs: EntityWorldMut type, ~2200 lines
  • filtered.rs: FilteredEntityRef and FilteredEntityMut types, ~780 lines
  • except.rs: EntityRefExcept and EntityMutExcept types, ~500 lines
  • entry.rs: ComponentEntry type, ~330 lines
  • component_fetch.rs: DynamicComponentFetch trait, ~360 lines

world_mut is still sizable, but that's just the sheer number of methods EntityWorldMut has. Splitting the methods across multiple files is possible, but that might be more annoying than a large file.

@JaySpruce JaySpruce added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 19, 2025
@alice-i-cecile alice-i-cecile added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Oct 20, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 20, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 20, 2025
Merged via the queue into bevyengine:main with commit 4adc34e Oct 20, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants