-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add method for reborrowing QueryData types #22025
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
6f0ab87 to
2538b79
Compare
NicoZweifel
left a comment
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.
This is pretty neat! This makes total sense to me in terms of utility functions and the like. I suggested a test that tests exactly this use case.
Other than that there are only a few minor things:
-
For the
EntityReftypes, we can dereference and use theCopyimplementations instead of manually creating the struct again, which is a bit more maintainable. -
The implemention of
Ref<>can also be slightly simplified sinceComponentTicksRefimplementsClone. -
I noticed a few missing square brackets in the doc comments.
chescock
left a comment
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.
Oh, neat!
Add
ReborrowQueryData, an optional subtrait (though almost all QueryData types should implement this in practice)
Do we have any QueryData types today that can't implement it? If not, then I would vote for putting the method directly on QueryData so that we don't need to add a new trait. We already require covariance through shrink(), so this wouldn't be that much more of a requirement.
- For the
EntityReftypes, we can dereference and use theCopyimplementations instead of manually creating the struct again, which is a bit more maintainable.- The implemention of
Ref<>can also be slightly simplified sinceComponentTicksRefimplementsClone.
Could we make Ref: Copy, too? I don't see any reason why it can't be, and that would avoid needing a Ref::reborrow() method entirely. (I guess it has to be a manual impl instead of #[derive(Copy)] since we don't want a T: Copy bound on the impl.)
2538b79 to
80779a9
Compare
alice-i-cecile
left a comment
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 would prefer to get the System::run_iter change in at the same time as this work. It's hard to evaluate the utility of this change in isolation, and compile time / binary size costs mean that adding more methods to core traits like this is not free.
|
closing these for now, will wrap into a later PR if perf looks good |
@ecoskey you can ping me if you want another review in a similar PR |
Objective
Allow reborrowing for QueryData types. The end goal here is to work towards a fast
System::run_iterapi, avoiding the overhead ofget_paramwith each iteration. Funnily enough the only system param that actually needs this isSingle, but it seems worthwhile to have anywaysNext steps:
SystemParam::reborrowSystemIterSolution
Add
reborrowmethod to QueryData