Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54289

Use std::to_chars in DecimalCounter

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Execution
    • Execution Team 2025-01-20

      When constructing a DecimalCounter starting at a nonzero value, currently we use our custom ItoA to parse the number into a string. It may be a bit cleaner to instead use std::to_chars.

      In SERVER-54106, we were unable to use std::to_chars due to the lack of a definition for std::__1::__itoa::__u32toa in Xcode 10, which we use for our macOS builds. Once we upgrade to Xcode 11, we may be able to use std::to_chars.

      DecimalCounter<T>(T start = 0)
          : _lastDigitIndex(
                start ? std::to_chars(_digits, _digits + kBufSize, start).ptr - _digits - 1 : 0),
            _counter(start) {}

            Assignee:
            gregory.noma@mongodb.com Gregory Noma
            Reporter:
            gregory.noma@mongodb.com Gregory Noma
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: