mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 03:25:55 +00:00
46ad16b70f
to_digit simplification (less jumps) I just realised we might be able to make use of the fact that changing case in ascii is easy to help simplify to_digit some more. It looks a bit cleaner and it looks like it's less jumps and there's less instructions in the generated assembly: https://godbolt.org/z/84Erh5dhz The benchmarks don't really tell me much. Maybe a slight improvement on the var radix. Before: ``` test char::methods::bench_to_digit_radix_10 ... bench: 53,819 ns/iter (+/- 8,314) test char::methods::bench_to_digit_radix_16 ... bench: 57,265 ns/iter (+/- 10,730) test char::methods::bench_to_digit_radix_2 ... bench: 55,077 ns/iter (+/- 5,431) test char::methods::bench_to_digit_radix_36 ... bench: 56,549 ns/iter (+/- 3,248) test char::methods::bench_to_digit_radix_var ... bench: 43,848 ns/iter (+/- 3,189) test char::methods::bench_to_digit_radix_10 ... bench: 51,707 ns/iter (+/- 10,946) test char::methods::bench_to_digit_radix_16 ... bench: 52,835 ns/iter (+/- 2,689) test char::methods::bench_to_digit_radix_2 ... bench: 51,012 ns/iter (+/- 2,746) test char::methods::bench_to_digit_radix_36 ... bench: 53,210 ns/iter (+/- 8,645) test char::methods::bench_to_digit_radix_var ... bench: 40,386 ns/iter (+/- 4,711) test char::methods::bench_to_digit_radix_10 ... bench: 54,088 ns/iter (+/- 5,677) test char::methods::bench_to_digit_radix_16 ... bench: 55,972 ns/iter (+/- 17,229) test char::methods::bench_to_digit_radix_2 ... bench: 52,083 ns/iter (+/- 2,425) test char::methods::bench_to_digit_radix_36 ... bench: 54,132 ns/iter (+/- 1,548) test char::methods::bench_to_digit_radix_var ... bench: 41,250 ns/iter (+/- 5,299) ``` After: ``` test char::methods::bench_to_digit_radix_10 ... bench: 48,907 ns/iter (+/- 19,449) test char::methods::bench_to_digit_radix_16 ... bench: 52,673 ns/iter (+/- 8,122) test char::methods::bench_to_digit_radix_2 ... bench: 48,509 ns/iter (+/- 2,885) test char::methods::bench_to_digit_radix_36 ... bench: 50,526 ns/iter (+/- 4,610) test char::methods::bench_to_digit_radix_var ... bench: 38,618 ns/iter (+/- 3,180) test char::methods::bench_to_digit_radix_10 ... bench: 54,202 ns/iter (+/- 6,994) test char::methods::bench_to_digit_radix_16 ... bench: 56,585 ns/iter (+/- 8,448) test char::methods::bench_to_digit_radix_2 ... bench: 50,548 ns/iter (+/- 1,674) test char::methods::bench_to_digit_radix_36 ... bench: 52,749 ns/iter (+/- 2,576) test char::methods::bench_to_digit_radix_var ... bench: 40,215 ns/iter (+/- 3,327) test char::methods::bench_to_digit_radix_10 ... bench: 50,233 ns/iter (+/- 22,272) test char::methods::bench_to_digit_radix_16 ... bench: 50,841 ns/iter (+/- 19,981) test char::methods::bench_to_digit_radix_2 ... bench: 50,386 ns/iter (+/- 4,555) test char::methods::bench_to_digit_radix_36 ... bench: 52,369 ns/iter (+/- 2,737) test char::methods::bench_to_digit_radix_var ... bench: 40,417 ns/iter (+/- 2,766) ``` I removed the likely as it resulted in a few less instructions. (It's not been in there long - I added it in the last to_digit iteration). |
||
---|---|---|
.. | ||
fmt | ||
hash | ||
iter | ||
num | ||
ops | ||
alloc.rs | ||
any.rs | ||
array.rs | ||
ascii.rs | ||
atomic.rs | ||
bool.rs | ||
cell.rs | ||
char.rs | ||
clone.rs | ||
cmp.rs | ||
const_ptr.rs | ||
intrinsics.rs | ||
lazy.rs | ||
lib.rs | ||
macros.rs | ||
manually_drop.rs | ||
mem.rs | ||
nonzero.rs | ||
ops.rs | ||
option.rs | ||
pattern.rs | ||
pin.rs | ||
ptr.rs | ||
result.rs | ||
slice.rs | ||
str_lossy.rs | ||
str.rs | ||
task.rs | ||
time.rs | ||
tuple.rs | ||
unicode.rs |