From c1ec29ace000ce4c733cde6948c87f9bc2370691 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 19 Mar 2019 08:32:15 +0100 Subject: [PATCH] ASCII uppercase: add "subtract shifted bool" benchmark --- src/libcore/benches/ascii.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcore/benches/ascii.rs b/src/libcore/benches/ascii.rs index 89e67cca4b7..968d28a9958 100644 --- a/src/libcore/benches/ascii.rs +++ b/src/libcore/benches/ascii.rs @@ -212,6 +212,18 @@ benches! { } } + fn case13_subtract_shifted_bool_match_range(bytes: &mut [u8]) { + fn is_ascii_lowercase(b: u8) -> bool { + match b { + b'a'...b'z' => true, + _ => false + } + } + for byte in bytes { + *byte -= (is_ascii_lowercase(*byte) as u8) << 5 + } + } + @iter is_ascii,