forked from LiveSplit/livesplit-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Custom Formatting for Integer Parts of Times
Going through the standard library's formatter is usually quite slow. And usually we want to show either minutes or seconds that are in the range from 0 to 59, or even tenths from 0 to 99. For those we can just define a lookup table where we look up the formatted strings and directly call `write_str` on the formatter instead of going through the `write!` macro, which would go through a lot more setup. Additionally we already have `itoa` as an indirect dependency which we now directly use for formatting integers that are not bound that way. `itoa` generally does the same algorithm as `std` but does so without going through any formatting machinery and is thus a lot faster, but also much less customizable. Overall this and LiveSplit#576 together result in a `~3.86x` performance improvement when formatting a time. | When | Time | |-------------|------------:| | Both PRs | `59.205 ns` | | Previous PR | `154.63 ns` | | Before | `228.47 ns` |
- Loading branch information
Showing
10 changed files
with
254 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.