So is this potentially performance improving?.
replies(2):
Sometimes people fail to appreciate how insanely fast a predictable branch really is.
fn validate_ascii(bytes: &[u8]) -> bool{
bytes.iter().fold(true, |acc, b| acc & (\*b <= 127))
}
This check will likely be the best for english text/code. You can check in varying size chunks depending on how common you think non-ascii will be. If its ascii you can move 128 bytes forward on avx2 in a couple of cycles.