diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-07-20 03:56:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 03:56:57 -0700 |
commit | 6860d110a843e882357d82d2a72205343339b11b (patch) | |
tree | 21a19adec954c9d46fd90d19e7fa30049d65b53e /src/.nuget | |
parent | 799b2a30a685a739d59a22b26b50e5da8616446f (diff) | |
download | coreclr-6860d110a843e882357d82d2a72205343339b11b.tar.gz coreclr-6860d110a843e882357d82d2a72205343339b11b.tar.bz2 coreclr-6860d110a843e882357d82d2a72205343339b11b.zip |
Improve throughput of TimeSpan.ToString/TryFormat with "g"/"G" (#19051)
* Improve throughput of TimeSpan.ToString/TryFormat with "g"/"G"
TimeSpan has three standard formats: "c", "g", and "G". Yesterday I updated its implementation with throughput improvements for "c" (the default) based on porting the design from Utf8Formatter; this PR does so for "g"/"G".
Initially I wasn't going to handle "g"/"G" as they factor in culture (Utf8Formatter doesn't), but even with accessing the current culture there are still significant wins to be had. I was also going to keep the "c" and "g"/"G" implementations separate, to avoid bogging down the default "c" formatting with additional conditions needed to support "g"/"G", but the overhead incurred for that turns out to be minimal enough that it's worth keeping one implementation rather than two mostly-similar ones... the impact on "c" is mostly within noise.
This PR makes a significant throughput improvement for "g"/"G" formatting. It also removes several unnecessary allocations, such that TryFormat with "g"/"G" is now allocation-free (and ToString just allocates the asked-for string).
* Address PR feedback
Diffstat (limited to 'src/.nuget')
0 files changed, 0 insertions, 0 deletions