Change Bundle::component_ids to return an iterator#21821
Merged
mockersf merged 9 commits intobevyengine:mainfrom Nov 13, 2025
Merged
Change Bundle::component_ids to return an iterator#21821mockersf merged 9 commits intobevyengine:mainfrom
Bundle::component_ids to return an iterator#21821mockersf merged 9 commits intobevyengine:mainfrom
Conversation
hymm
commented
Nov 13, 2025
| } | ||
| } | ||
| let generics = ast.generics; | ||
| let generics_ty_list = generics.type_params().map(|p| p.ident.clone()); |
Contributor
Author
There was a problem hiding this comment.
I think this is the right way to get a iterator over the generic identifiers, but not very good at macros or syn, so someone else should probably confirm. ty_generics includes the angle brackets and is not a list.
cBournhonesque
approved these changes
Nov 13, 2025
chescock
approved these changes
Nov 13, 2025
Contributor
chescock
left a comment
There was a problem hiding this comment.
Looks good!
I checked the assembly myself for a simple method calling B::component_ids(components).collect(). And it got better! A bunch of calls to RawVec<T,A>::grow_one got removed, probably because once() and chain() impl TrustedLen.
mockersf
approved these changes
Nov 13, 2025
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Nov 15, 2025
# Objective - As part of bevyengine#21780, I need a way to iterate over the component ids of a bundle for `Entity*Except` conflict checking without allocating. Pulled this out as it changes some unrelated code too. ## Solution - Change `Bundle::component_ids` and `Bundle::get_component_ids` to return an iterator instead of taking a closure. In theory I would expect this to compile to the same asm. I would also argue that using an iterator is a more natural api for this than the closure. It probably took a closure before because expressing that the iterator doesn't capture the `&mut ComponentRegistrator` lifetime wasn't possible without the `use` syntax. - Removed some #[allow(deprecated)] in the Bundle macro that was missed. ## Testing - Checked the asm for `hook_on_add` in the observers example for to confirm it was still the same. This is a pretty simple example though, so not sure how good of a check this is. - None of the code touched are in any hot paths, but ran the spawn and insert benches. Any changes seem to be in the noise.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Nov 16, 2025
# Objective - As part of bevyengine#21780, I need a way to iterate over the component ids of a bundle for `Entity*Except` conflict checking without allocating. Pulled this out as it changes some unrelated code too. ## Solution - Change `Bundle::component_ids` and `Bundle::get_component_ids` to return an iterator instead of taking a closure. In theory I would expect this to compile to the same asm. I would also argue that using an iterator is a more natural api for this than the closure. It probably took a closure before because expressing that the iterator doesn't capture the `&mut ComponentRegistrator` lifetime wasn't possible without the `use` syntax. - Removed some #[allow(deprecated)] in the Bundle macro that was missed. ## Testing - Checked the asm for `hook_on_add` in the observers example for to confirm it was still the same. This is a pretty simple example though, so not sure how good of a check this is. - None of the code touched are in any hot paths, but ran the spawn and insert benches. Any changes seem to be in the noise.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Nov 16, 2025
# Objective - As part of bevyengine#21780, I need a way to iterate over the component ids of a bundle for `Entity*Except` conflict checking without allocating. Pulled this out as it changes some unrelated code too. ## Solution - Change `Bundle::component_ids` and `Bundle::get_component_ids` to return an iterator instead of taking a closure. In theory I would expect this to compile to the same asm. I would also argue that using an iterator is a more natural api for this than the closure. It probably took a closure before because expressing that the iterator doesn't capture the `&mut ComponentRegistrator` lifetime wasn't possible without the `use` syntax. - Removed some #[allow(deprecated)] in the Bundle macro that was missed. ## Testing - Checked the asm for `hook_on_add` in the observers example for to confirm it was still the same. This is a pretty simple example though, so not sure how good of a check this is. - None of the code touched are in any hot paths, but ran the spawn and insert benches. Any changes seem to be in the noise.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Nov 18, 2025
# Objective - As part of bevyengine#21780, I need a way to iterate over the component ids of a bundle for `Entity*Except` conflict checking without allocating. Pulled this out as it changes some unrelated code too. ## Solution - Change `Bundle::component_ids` and `Bundle::get_component_ids` to return an iterator instead of taking a closure. In theory I would expect this to compile to the same asm. I would also argue that using an iterator is a more natural api for this than the closure. It probably took a closure before because expressing that the iterator doesn't capture the `&mut ComponentRegistrator` lifetime wasn't possible without the `use` syntax. - Removed some #[allow(deprecated)] in the Bundle macro that was missed. ## Testing - Checked the asm for `hook_on_add` in the observers example for to confirm it was still the same. This is a pretty simple example though, so not sure how good of a check this is. - None of the code touched are in any hot paths, but ran the spawn and insert benches. Any changes seem to be in the noise.
beicause
pushed a commit
to beicause/bevy
that referenced
this pull request
Nov 26, 2025
# Objective - As part of bevyengine#21780, I need a way to iterate over the component ids of a bundle for `Entity*Except` conflict checking without allocating. Pulled this out as it changes some unrelated code too. ## Solution - Change `Bundle::component_ids` and `Bundle::get_component_ids` to return an iterator instead of taking a closure. In theory I would expect this to compile to the same asm. I would also argue that using an iterator is a more natural api for this than the closure. It probably took a closure before because expressing that the iterator doesn't capture the `&mut ComponentRegistrator` lifetime wasn't possible without the `use` syntax. - Removed some #[allow(deprecated)] in the Bundle macro that was missed. ## Testing - Checked the asm for `hook_on_add` in the observers example for to confirm it was still the same. This is a pretty simple example though, so not sure how good of a check this is. - None of the code touched are in any hot paths, but ran the spawn and insert benches. Any changes seem to be in the noise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Entity*Exceptconflict checking without allocating. Pulled this out as it changes some unrelated code too.Solution
Bundle::component_idsandBundle::get_component_idsto return an iterator instead of taking a closure. In theory I would expect this to compile to the same asm. I would also argue that using an iterator is a more natural api for this than the closure. It probably took a closure before because expressing that the iterator doesn't capture the&mut ComponentRegistratorlifetime wasn't possible without theusesyntax.Testing
hook_on_addin the observers example for to confirm it was still the same. This is a pretty simple example though, so not sure how good of a check this is.