![]() # Objective Most of the impls derived for `#[derive(Reflect)]` have one set of type bounds per field, like so: ``` f32: ::bevy::reflect::FromReflect + ::bevy::reflect::TypePath + ::bevy::reflect::MaybeTyped + ::bevy::reflect::__macro_exports::RegisterForReflection, ``` If multiple fields have the same type, the bounds are repeated uselessly. This can only hurt compile time and clogs up the `cargo expand` output. Avoiding this will help with https://github.com/bevyengine/bevy/issues/19873. ## Solution Use a hashset when collecting the bounds to eliminate duplicates. ## Testing I used cargo expand to confirm the duplicate bounds are no longer produced. `-Zmacro-stats` outputs tells me this reduces the size of the `Reflect` code produced for `bevy_ui` from 1_544_696 bytes to 1_467_967 bytes, a 5% drop. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT |