Skip to content
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

Add a way to cache a QueryLens #12271

Open
hymm opened this issue Mar 3, 2024 · 0 comments
Open

Add a way to cache a QueryLens #12271

hymm opened this issue Mar 3, 2024 · 0 comments
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible

Comments

@hymm
Copy link
Contributor

hymm commented 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.

@hymm hymm added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Mar 3, 2024
@hymm hymm mentioned this issue Mar 3, 2024
@TrialDragon TrialDragon added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Mar 3, 2024
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-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

2 participants