Skip to content

strconv: mantissa digit parsing reads one character at a time #3825

Description

@bobzhang

strconv/number.mbt:104 (and its duplicate internal/strconv/strconv_number.mbt:104) carries this TODO on the float-parsing hot path:

TODO: optimization chance. In the original Rust implementation, [they] try to parse 8 digits at a time [into a u64].

parse_digits currently accumulates digit-by-digit. The Eisel-Lemire reference implementation reads 8 bytes into a u64 and validates/converts them in a handful of arithmetic ops, which is a substantial constant-factor win for long mantissas.

Care needed around digit-count/overflow boundaries and the two copies of the code (strconv/ and internal/strconv/ must stay in sync — or better, be deduplicated as part of this work).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions