Skip to content

Commit

Permalink
Use FormattingHelpers.Count{Hex}Digits in {u}int/long.ToString/TryFormat
Browse files Browse the repository at this point in the history
Currently we create a temporary buffer on the stack, format into it, and then copy from that stack buffer into either the target span (for TryFormat) or into a new string (for ToString.

Following the approach as (and sharing the same code from) Utf8Formatter, where it first counts the number of digits in the output in order to determine an exact length, this commit changes the implementation to skip the temporary buffer and just format directly into the destination span or string.

This results in a very measurable performance boost.
  • Loading branch information
stephentoub committed Apr 5, 2018
1 parent 1acd737 commit b41c8cc
Showing 1 changed file with 196 additions and 139 deletions.
Loading

0 comments on commit b41c8cc

Please sign in to comment.