Skip to content

Commit

Permalink
Auto merge of #110389 - mazong1123:add-shortcut-for-grisu3, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

Add shortcut for Grisu3 algorithm.

While Grisu3 is way more faster for most numbers compare to Dragon4, the fall back to Dragon4 procedure for certain numbers could cause some performance regressions compare to use Dragon4 directly. Mitigating the regression caused by falling back is important for a largely used core library.

In Grisu3 algorithm implementation, there's a shortcut to jump out earlier when the fractional or integrals cannot meet the requirement of requested digits. This could significantly improve the performance of converting floating number to string as it falls back even without starting trying the algorithm.

The original idea is from the [.NET implementation](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Number.Grisu3.cs#L602-L615) and the code was originally added in [this PR](dotnet/coreclr#14646 (comment)). This shortcut has been shipped long time ago and has been proved working.

Fix #110129
  • Loading branch information
bors committed Apr 25, 2023
2 parents afc1064 + c353ea0 commit ba789e0
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit ba789e0

Please sign in to comment.