diff options
| author | Thom Chiovoloni <tchiovoloni@mozilla.com> | 2020-07-06 07:43:32 -0700 |
|---|---|---|
| committer | Thom Chiovoloni <tchiovoloni@mozilla.com> | 2020-07-06 07:43:38 -0700 |
| commit | a150dcc872b4f003c4a0e4cd7bb0e7c51ec791b2 (patch) | |
| tree | 2d611b82754b721a0321295b8f76aa64e4dc000f /src/libcore | |
| parent | dc4a644980e919539962f2bbf267381c20441f8e (diff) | |
| download | rust-a150dcc872b4f003c4a0e4cd7bb0e7c51ec791b2.tar.gz rust-a150dcc872b4f003c4a0e4cd7bb0e7c51ec791b2.zip | |
Remove pointless `black_box` call, add a comment about the `unaligned_` benches, and clean up stray semicolon
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/benches/ascii.rs | 2 | ||||
| -rw-r--r-- | src/libcore/benches/ascii/is_ascii.rs | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/libcore/benches/ascii.rs b/src/libcore/benches/ascii.rs index 6a4d706cff6..05dd7adff1f 100644 --- a/src/libcore/benches/ascii.rs +++ b/src/libcore/benches/ascii.rs @@ -60,7 +60,7 @@ macro_rules! benches { } )+ } - }; + } } use test::black_box; diff --git a/src/libcore/benches/ascii/is_ascii.rs b/src/libcore/benches/ascii/is_ascii.rs index 45ba2f8fe82..729b0a04eb6 100644 --- a/src/libcore/benches/ascii/is_ascii.rs +++ b/src/libcore/benches/ascii/is_ascii.rs @@ -7,7 +7,9 @@ macro_rules! benches { benches!(mod short SHORT[..] $($name $arg $body)+); benches!(mod medium MEDIUM[..] $($name $arg $body)+); benches!(mod long LONG[..] $($name $arg $body)+); - + // Ensure we benchmark cases where the functions are called with strings + // that are not perfectly aligned or have a length which is not a + // multiple of size_of::<usize>() (or both) benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+); benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+); benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+); @@ -22,8 +24,7 @@ macro_rules! benches { bencher.bytes = $input[$range].len() as u64; let mut vec = $input.as_bytes().to_vec(); bencher.iter(|| { - black_box(&mut vec); - let $arg = black_box(&vec[$range]); + let $arg: &[u8] = &black_box(&mut vec)[$range]; black_box($body) }) } |
