Update library/core/src/num/mod.rs

Co-authored-by: LingMan <LingMan@users.noreply.github.com>
This commit is contained in:
Squirrel 2021-05-18 18:22:04 +01:00 committed by gilescope
parent 13d85ea880
commit 48b7cc49a3
No known key found for this signature in database
GPG Key ID: 631F6352D4A949EF

View File

@ -1094,8 +1094,8 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par
for &c in digits {
// When `radix` is passed in as a literal, rather than doing a slow `imul`
// then the compiler can use a shift if `radix` is a power of 2.
// (*10 can also be turned into *8 + *2).
// the compiler can use shifts if `radix` can be expressed as a
// sum of powers of 2 (x*10 can be written as x*8 + x*2).
// When the compiler can't use these optimisations,
// there is a latency of several cycles so doing the
// multiply before we need to use the result helps.