bevy/crates/bevy_hierarchy/src
Nicola Papale a634075a39
Inline trivial methods in bevy_hierarchy (#11332)
# Objective

In #11330 I found out that `Parent::get` didn't get inlined, **even with
LTO on**!

This means that just to access a field, we have an instruction cache
invalidation, we will move some registers to the stack, will jump to new
instructions, move the field into a register, then do the same dance in
the other direction to go back to the call site.

## Solution

Mark trivial functions as `#[inline]`.

`inline(always)` may increase compilation time proportional to how many
time the function is called **and the size of the function marked with
`inline`**. Since we mark as `inline` functions that consists in a
single instruction, the cost is absolutely negligible.

I also took the opportunity to `inline` other functions. I'm not as
confident that marking functions calling other functions as `inline`
works similarly to very simple functions, so I used `inline` over
`inline(always)`, which doesn't have the same downsides as
`inline(always)`.

More information on inlining in rust:
https://nnethercote.github.io/perf-book/inlining.html
2024-01-13 22:20:50 +00:00
..
components Inline trivial methods in bevy_hierarchy (#11332) 2024-01-13 22:20:50 +00:00
child_builder.rs Rename "AddChild" to "PushChild" (#11194) 2024-01-04 16:06:14 +00:00
events.rs Require #[derive(Event)] on all Events (#7086) 2023-06-06 14:44:32 +00:00
hierarchy.rs Simplify equality assertions (#10988) 2023-12-16 23:58:41 +00:00
lib.rs Add bevy_hierarchy Crate and plugin documentation (#10951) 2024-01-02 19:40:14 +00:00
query_extension.rs Rename Q type parameter to D when referring to WorldQueryData (#10782) 2023-12-13 18:50:46 +00:00
valid_parent_check_plugin.rs Make bevy_app and reflect opt-out for bevy_hierarchy. (#10721) 2023-11-25 03:05:38 +00:00