Skip to content

Commit

Permalink
feat: update black_box() usage
Browse files Browse the repository at this point in the history
See rust-lang/rust#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.
  • Loading branch information
BD103 committed Dec 7, 2024
1 parent ab11ede commit 834f1c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion benches/benches/bevy_reflect/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_reflect/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down

0 comments on commit 834f1c3

Please sign in to comment.