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

[Merged by Bors] - keep track of type name in NodeState #1444

Closed

Conversation

jakobhellermann
Copy link
Contributor

Adds the original type_name to NodeState, enabling plugins like this.
This does increase the NodeState type by 16 bytes, but it is already 176 so it's not that big of an increase.

@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change A-Rendering Drawing game state to the screen labels Feb 17, 2021
@@ -131,6 +132,7 @@ impl NodeState {
input_slots: ResourceSlots::from(node.input()),
output_slots: ResourceSlots::from(node.output()),
node: Box::new(node),
type_name: Some(std::any::type_name::<T>()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it always have a value? Is the Option needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In bevy all uses of NodeState supply the type name, so the option isn’t needed. However I wasn’t sure whether there are use cases where the type name is not available, and the size of Option<&str> is the same as &str anyway.

I don’t really care which one it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its less about size and more about adding another branch to unwrap the option (which has performance and code complexity implications). I think I'd rather opt for non-options first, then add them if/when we hit a case where they're needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it now.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 17, 2021
Base automatically changed from master to main February 19, 2021 20:44
@cart
Copy link
Member

cart commented Feb 22, 2021

bors r+

bors bot pushed a commit that referenced this pull request Feb 22, 2021
Adds the original type_name to `NodeState`, enabling plugins like [this](https://github.com/jakobhellermann/bevy_mod_debugdump).
This does increase the `NodeState` type by 16 bytes, but it is already 176 so it's not that big of an increase.
@bors bors bot changed the title keep track of type name in NodeState [Merged by Bors] - keep track of type name in NodeState Feb 22, 2021
@bors bors bot closed this Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants