-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Move implementations of Query methods from QueryState to Query.
#17822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add missing `iter_many_unique_inner` and `single_inner` methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very satisfying PR, it's nice to see it all come together
… `QueryState` to the file with `Query`.
|
We should run the query benches to make sure nothing weird is happening. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!
That makes sense! I'll try to figure out how to do that, but I probably won't have time until Friday. |
# Conflicts: # crates/bevy_ecs/src/system/query.rs
…_unchecked_manual` for parallel iteration.
…s()` and make it a safety requirement.
|
I ran the benches, and found some slowdowns caused by extra calls to I changed the safety requirements of the |
|
Here are the results of running |
Objective
Simplify the API surface by removing duplicated functionality between
QueryandQueryState.Reduce the amount of
unsafecode required inQueryState.This is a follow-up to #15858.
Solution
Move implementations of
Querymethods fromQueryStatetoQuery. Instead of the original methods being onQueryState, withQuerymethods calling them by passing the individual parameters, the original methods are now onQuery, withQueryStatemethods calling them by constructing aQuery.This also adds two
_innermethods that were missed in #15858:iter_many_unique_innerandsingle_inner.One goal here is to be able to deprecate and eventually remove many of the methods on
QueryState, reducing the overall API surface. (I expected to do that in this PR, but this change was large enough on its own!) Now that theQueryStatemethods each consist of a simple expression likeself.query(world).get_inner(entity), a future PR can deprecate some or all of them with simple migration instructions.The other goal is to reduce the amount of
unsafecode. The current implementation of a read-only method likeQueryState::getdirectly calls theunsafe fn get_unchecked_manualand needs to repeat the proof that&Worldhas enough access. With this change,QueryState::getis entirely safe code, with the proof that&Worldhas enough access done by thequery()method and shared across all read-only operations.Future Work
The next step will be to mark the
QueryStatemethods as#[deprecated]and migrate callers to the methods onQuery.