From 7843e2792dce0f20d23b3c1cca51652013bef0ea Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 14 Nov 2018 11:26:00 +0100 Subject: [PATCH] core/char: Add comment to `to_digit()` --- src/libcore/char/methods.rs | 3 +++ 1 file changed, 3 insertions(+) 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 @@ pub fn is_digit(self, radix: u32) -> bool { #[inline] pub fn to_digit(self, radix: u32) -> Option { 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,