bevy/crates
James Liu 6dda873ddc
Reduce branching when inserting components (#8053)
# Objective
We're currently using an unconditional `unwrap` in multiple locations
when inserting bundles into an entity when we know it will never fail.
This adds a large amount of extra branching that could be avoided on in
release builds.

## Solution
Use `DebugCheckedUnwrap` in bundle insertion code where relevant. Add
and update the safety comments to match.

This should remove the panicking branches from release builds, which has
a significant impact on the generated code:
https://github.com/james7132/bevy_asm_tests/compare/less-panicking-bundles#diff-e55a27cfb1615846ed3b6472f15a1aed66ed394d3d0739b3117f95cf90f46951R2086
shows about a 10% reduction in the number of generated instructions for
`EntityMut::insert`, `EntityMut::remove`, `EntityMut::take`, and related
functions.

---------

Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2023-03-21 20:37:25 +00:00
..
bevy_a11y chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_animation Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_app Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_asset Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_audio Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_core Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_core_pipeline Make render graph slots optional for most cases (#8109) 2023-03-21 20:11:13 +00:00
bevy_derive chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_diagnostic Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_dylib chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_dynamic_plugin chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_ecs Reduce branching when inserting components (#8053) 2023-03-21 20:37:25 +00:00
bevy_ecs_compile_fail_tests Update trybuild tests for Rust 1.68 (#8002) 2023-03-09 15:46:06 +00:00
bevy_encase_derive chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_gilrs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_gizmos Fix crash when enabling HDR on 2d cameras (#8151) 2023-03-21 18:31:52 +00:00
bevy_gltf chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_hierarchy Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_input Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_internal Immediate Mode Line/Gizmo Drawing (#6529) 2023-03-20 20:57:54 +00:00
bevy_log chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_macro_utils chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_math chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_mikktspace chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_pbr Make render graph slots optional for most cases (#8109) 2023-03-21 20:11:13 +00:00
bevy_ptr chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_reflect Fix typo in utility.rs (#7997) 2023-03-09 09:20:45 +00:00
bevy_reflect_compile_fail_tests Update trybuild tests for Rust 1.68 (#8002) 2023-03-09 15:46:06 +00:00
bevy_render Make render graph slots optional for most cases (#8109) 2023-03-21 20:11:13 +00:00
bevy_scene (De) serialize resources in scenes (#6846) 2023-03-20 21:17:02 +00:00
bevy_sprite Derive Copy and Clone for Collision (#8121) 2023-03-18 04:55:31 +00:00
bevy_tasks chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_text Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_time Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_transform Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_ui Make render graph slots optional for most cases (#8109) 2023-03-21 20:11:13 +00:00
bevy_utils chore: Release (#7920) 2023-03-06 05:13:36 +00:00
bevy_window Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bevy_winit Add documentation comments to bevy_winit (#8115) 2023-03-21 19:59:30 +00:00