diff options
| author | Tobias Bieniek <tobias.bieniek@gmail.com> | 2018-11-14 11:26:00 +0100 |
|---|---|---|
| committer | Tobias Bieniek <tobias.bieniek@gmail.com> | 2018-11-14 11:26:00 +0100 |
| commit | 7843e2792dce0f20d23b3c1cca51652013bef0ea (patch) | |
| tree | e58fdb9538b49727c471ff5294a0e2886ce7f192 | |
| parent | 64a517265297cc1d4e9e116dcbb06561c063c3d4 (diff) | |
| download | rust-7843e2792dce0f20d23b3c1cca51652013bef0ea.tar.gz rust-7843e2792dce0f20d23b3c1cca51652013bef0ea.zip | |
core/char: Add comment to `to_digit()`
| -rw-r--r-- | src/libcore/char/methods.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index 4207b3c776c..d6fcff644ac 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -122,6 +122,9 @@ impl char { #[inline] pub fn to_digit(self, radix: u32) -> Option<u32> { assert!(radix <= 36, "to_digit: radix is too high (maximum 36)"); + + // the code is split up here to improve execution speed for cases where + // the `radix` is constant and 10 or smaller let val = if radix <= 10 { match self { '0' ..= '9' => self as u32 - '0' as u32, |
