You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
make "dec" and ryu functions faster and simpler (#51273)
We had some common code in `Ryu.append_c_digits` that can be combined
with Base logic for the same thing. But it turns out all of this
duplicated code in Ryu seems to just make it run slightly slower in most
cases. The old version had many more branches to check, even though
often numbers are small, so only the last check is meaningful. But the
assumption that it would be faster even if all of them were used also
seems to not hold up in practice. Particularly for a function like
`append_nine_digits` which unrolls completely, but the complicated
version has slightly more data dependencies because of they way it is
written.
Similarly, we replace `unsafe_copy` with `@inbounds[]`, since this is
better for the optimizer, which doesn't need to treat this operation as
an unknown reference escape.
Lastly, we use the append_nine_digits trick from Ryu to make printing of
arbitrary big numbers much faster.
```
julia> @Btime string(typemax(Int128))
402.345 ns (2 allocations: 120 bytes) # before
151.139 ns (2 allocations: 120 bytes) # after
```
0 commit comments