Skip to content

Commit a150dcc

Browse files
author
Thom Chiovoloni
committed
Remove pointless black_box call, add a comment about the unaligned_ benches, and clean up stray semicolon
1 parent dc4a644 commit a150dcc

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/libcore/benches/ascii.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ macro_rules! benches {
6060
}
6161
)+
6262
}
63-
};
63+
}
6464
}
6565

6666
use test::black_box;

src/libcore/benches/ascii/is_ascii.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ macro_rules! benches {
77
benches!(mod short SHORT[..] $($name $arg $body)+);
88
benches!(mod medium MEDIUM[..] $($name $arg $body)+);
99
benches!(mod long LONG[..] $($name $arg $body)+);
10-
10+
// Ensure we benchmark cases where the functions are called with strings
11+
// that are not perfectly aligned or have a length which is not a
12+
// multiple of size_of::<usize>() (or both)
1113
benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+);
1214
benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+);
1315
benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+);
@@ -22,8 +24,7 @@ macro_rules! benches {
2224
bencher.bytes = $input[$range].len() as u64;
2325
let mut vec = $input.as_bytes().to_vec();
2426
bencher.iter(|| {
25-
black_box(&mut vec);
26-
let $arg = black_box(&vec[$range]);
27+
let $arg: &[u8] = &black_box(&mut vec)[$range];
2728
black_box($body)
2829
})
2930
}

0 commit comments

Comments
 (0)