Add get_change_ticks method to EntityRef and EntityMut #2539
+28
−0
Conversation
As this is a little advanced, some doc comments would be nice |
cart
reviewed
Aug 10, 2021
pub fn get_change_ticks<T: Component>(&self) -> Option<&'w ComponentTicks> { | ||
// SAFE: entity location is valid and returned component is of type T | ||
unsafe { | ||
get_component_and_ticks_with_type( |
I know you're trying to reuse code here, but we don't need to retrieve the component for this operation. This seems like the sort of small inefficiency that we'd merge and then forget about. A theoretical get_ticks
and the existing get_component
and get_component_with_ticks
methods probably have some refactoring potential to share code. They all need to "get the entity's offset in each storage". This seems like a relatively trivial refactor for Table storage, but Sparse Set storage would probably need some new get_with_dense_index_unchecked() apis.
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.
Direct access to the change ticks is useful for integrating the reliable change detection with external stuff.
The text was updated successfully, but these errors were encountered: