From ee94d48f5085002566a5a6eada9225a10ff067cb Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 7 Dec 2024 10:18:26 -0500 Subject: [PATCH] feat: update `black_box()` usage See https://github.com/rust-lang/rust/pull/133942, there's not much point in using `black_box()` on a unit type, especially since `map.insert()` has side-effects and will be executed. --- benches/benches/bevy_reflect/map.rs | 2 +- benches/benches/bevy_reflect/struct.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benches/benches/bevy_reflect/map.rs b/benches/benches/bevy_reflect/map.rs index 69963316b6..054dcf9570 100644 --- a/benches/benches/bevy_reflect/map.rs +++ b/benches/benches/bevy_reflect/map.rs @@ -265,7 +265,7 @@ fn dynamic_map_insert(criterion: &mut Criterion) { |mut map| { for i in 0..size as u64 { let key = black_box(i); - black_box(map.insert(key, i)); + map.insert(key, black_box(i)); } }, BatchSize::SmallInput, diff --git a/benches/benches/bevy_reflect/struct.rs b/benches/benches/bevy_reflect/struct.rs index 5fc3a462c5..dfd324e705 100644 --- a/benches/benches/bevy_reflect/struct.rs +++ b/benches/benches/bevy_reflect/struct.rs @@ -313,7 +313,7 @@ fn dynamic_struct_insert(criterion: &mut Criterion) { bencher.iter_batched( || s.clone_dynamic(), |mut s| { - black_box(s.insert(black_box(&field), ())); + s.insert(black_box(&field), ()); }, BatchSize::SmallInput, );