Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using as_bytes instead of chars() since All the inputs and outputs are in ASCII. Rust Strings and &str are utf8, so while one might expect "Hello".chars() to be simple, it has to check each char to see if it's 1, 2, 3, or 4 u8s long. If we know a &str is ASCII then we can call .as_bytes() and refer to the underlying data as a &[u8] (byte slice). Iterating over a slice of ASCII bytes is much quicker as there are no codepoints involved - every ASCII byte is one u8 long.
- Loading branch information