Open
Description
opened on Mar 3, 2024
What problem does this solve or what need does it fill?
Creating a QueryLens for a transmute or join operation requires creating the query state and checking to make sure that the new state is a valid state. It should be possible to cache some of this to skip these.
What solution would you like?
Provide a safe wrapper around a QueryLens that allows updating the internal QueryState by passing in the updated Query(s). This would update all the variable internal state like the matched_table's and matched_archetypes's.
fn my_system(
q: Query<(&A, &B), With<C>>,
// only allows transmuting a Query<((&A, &B, With<C>)> to a Query<&B>
transmuter: Transmuter<((&A, &B), With<C>), &B>) {
// Transmute the query to a Query<&B>
let new_q = transmuter.transmute(&mut q);
// ...
}
What alternative(s) have you considered?
We could instead just have a method on QueryState that allows reusing the internal State
, but still requires checking the compatibility. This would at least reduce some of the costs, but be a lot less verbose.
Activity