Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement IUtf8SpanFormattable on all the numeric types in corelib #84587

Merged
merged 4 commits into from
Apr 14, 2023

Commits on Apr 12, 2023

  1. Implement IUtf8SpanFormattable on all the numeric types in corelib

    Augments SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Int128, UInt128, Half, Single, Double, NFloat, and Decimal.
    
    Also fixes corelib TODOs around using IUtf8SpanFormattable.
    
    And removes some duplicate code from Utf8Formatter.
    
    There is still more consolidation to be done between FormattingHelpers and Number.Formatting.
    stephentoub committed Apr 12, 2023
    Configuration menu
    Copy the full SHA
    1a3c5d2 View commit details
    Browse the repository at this point in the history
  2. Address regressions from previous formatting changes

    - Use an internal interface implemented by char and byte to have dedicated CastFrom methods that are always inlineable due to very small size.
    - Use pointers in some core formatting routines to avoid needing bulky IL for manipulating refs with spans, making various members more inlineable.
    - Avoid Encoding.UTF8.GetBytes in various code paths by caching more UTF8 sequences on DateTimeFormatInfo and NumberFormatInfo
    - Change FormatCustomizedTimeZone to special-case 2 vs 3+ tokens in order to avoid extra AppendSpan calls
    - Fix growth logic in ValueListBuilder to not forcibly grow more than is needed
    - Inline ValueListBuilder.AppendSpan and remove some bounds checks (at least on 64-bit)
    - Change FormatDigits to special-case lengths of 1/2/4 and to use existing formatting routines rather than a custom one
    - Remove the FormatDigits wrapper overload and just have all calls go to the main workhorse method.
    - Remove the use of "..."u8 in R/O formatting that leads to needing to use additional span-based helpers.  The minimal gain on coreclr isn't worth the extra complication
    - Changed some switches to include half the cases based on lowercasing the ASCII input char
    - Moved Date/TimeOnly charsWritten into Try method to be closer to the source of truth rather than having the value far aware (this isn't for perf and could possibly even be a microregression, so I included it here to ensure it's not measurable).
    stephentoub committed Apr 12, 2023
    Configuration menu
    Copy the full SHA
    b593d86 View commit details
    Browse the repository at this point in the history

Commits on Apr 14, 2023

  1. Configuration menu
    Copy the full SHA
    3166efa View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    72601d3 View commit details
    Browse the repository at this point in the history