bevy/crates
Nicholas Nethercote 5aa520eac0
bevy_reflect: avoid useless with_{custom_attributes,docs} calls (#19875)
# Objective

`#[derive(Reflect)]` derives `Typed` impls whose `type_info` methods
contain useless calls to `with_custom_attributes` and `with_docs`, e.g.:
```
::bevy::reflect::NamedField:🆕:<f32>("x")
    .with_custom_attributes(
        ::bevy::reflect::attributes::CustomAttributes::default()
    )
    .with_docs(::core::option::Option::None),
```
This hurts compile times and makes the `cargo expand` output harder to
read. It might also hurt runtime speed, depending on whether the
compiler can optimize away the no-op methods.

Avoiding this will help with #19873.

## Solution

Check if the attributes/docs are empty before appending the method
calls.

## Testing

I used `cargo expand` to confirm the useless calls are no longer
produced.

`-Zmacro-stats` outputs tells me this reduces the size of the `Reflect`
impls produced for `bevy_ui` from 1_544_696 bytes to 1_511_214 bytes, a
2.2% drop. Only a small improvement, but it's a start.
2025-06-30 23:29:24 +00:00
..
bevy_a11y
bevy_animation Prevent AnimationGraph from serializing AssetIds. (#19615) 2025-06-30 22:26:05 +00:00
bevy_anti_aliasing Add UVec to_extents helper method (#19807) 2025-06-26 20:53:49 +00:00
bevy_app Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_asset Restructure the logic in AssetServer::load_internal to avoid using weak handles. (#19634) 2025-06-30 22:39:59 +00:00
bevy_audio Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_color Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_core_pipeline Split LatePrepassNode query in a few groups (#19840) 2025-06-30 23:08:27 +00:00
bevy_core_widgets Update bevy website link in newer code (#19874) 2025-06-30 23:24:36 +00:00
bevy_derive
bevy_dev_tools Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_diagnostic updating: very very minorly (#19827) 2025-06-26 21:48:20 +00:00
bevy_dylib
bevy_ecs Spawn batch with relationship (#19519) 2025-06-30 22:13:38 +00:00
bevy_encase_derive
bevy_feathers Update bevy website link in newer code (#19874) 2025-06-30 23:24:36 +00:00
bevy_gilrs
bevy_gizmos Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
bevy_gltf Nudge users into migrating to new default glTF coordinate conversion (#19816) 2025-06-28 18:35:41 +00:00
bevy_image optimize ktx2 level data concatenation (#19845) 2025-06-29 21:59:56 +00:00
bevy_input bevy_input: build warnings without bevy_reflect (#19862) 2025-06-29 17:13:43 +00:00
bevy_input_focus Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_internal Light Textures (#18031) 2025-06-30 21:56:17 +00:00
bevy_log Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_macro_utils
bevy_math Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_mesh Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_mikktspace
bevy_pbr Light Textures (#18031) 2025-06-30 21:56:17 +00:00
bevy_picking
bevy_platform bevy_platform: clippy without default features (#19860) 2025-06-29 17:12:57 +00:00
bevy_ptr
bevy_reflect bevy_reflect: avoid useless with_{custom_attributes,docs} calls (#19875) 2025-06-30 23:29:24 +00:00
bevy_remote Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_render bevy_render: fix clippy on wasm (#19872) 2025-06-29 22:09:37 +00:00
bevy_scene Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_solari Update bevy website link in newer code (#19874) 2025-06-30 23:24:36 +00:00
bevy_sprite Fix sprite picking viewport (#19747) 2025-06-30 22:46:44 +00:00
bevy_state Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_tasks
bevy_text Bevy Feathers: an opinionated widget toolkit for building Bevy tooling (#19730) 2025-06-28 19:52:13 +00:00
bevy_time
bevy_transform
bevy_ui Fix ui picking outside the viewport (#19744) 2025-06-30 22:46:56 +00:00
bevy_utils bevy_utils: clippy without debug feature enabled (#19861) 2025-06-29 17:13:27 +00:00
bevy_window bevy_window: fix compilation without default features (#19870) 2025-06-30 20:51:52 +00:00
bevy_winit bevy_winit: fix compile and clippy on wasm (#19869) 2025-06-29 21:30:28 +00:00