fastfloat / fast_float

Fast and exact implementation of the C++ from_chars functions for number types: 4x to 10x faster than strtod, part of GCC 12, Chromium and WebKit/Safari
Apache License 2.0
1.35k stars 124 forks source link

Suggestion: provide from_chars_advanced overload or other function name that takes parsed_number_string_t<UC> argument #248

Open zejal opened 4 months ago

zejal commented 4 months ago

Idea would be to allow for existing parsing code and avoid copy pasting remainder of from_chars_advanced function. Existing parser code would fill the parsed_number_string structure as appropriate.

lemire commented 4 months ago

It is difficult to discuss these things in the abstract. My recommendation is that you make a pull request and we can look at the code.

zejal commented 4 months ago

Not hugely familiar with github at this stage, unfortunately. Based on last released fast_float.hpp you'd have:

template<typename T, typename UC> FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC> from_chars_advanced(const parsed_number_string_t<UC>& pns, T &value) noexcept { // assert pns.valid ? or explicit check as in current function ? probably leave the check responsibility to caller ? answer.ec = std::errc(); // be optimistic // same lines as in existing from_chars_advanced. // ... }

lemire commented 4 months ago

@zejal Can you propose a patch?

zejal commented 4 months ago

Sure, I'll do my best to get familiar with how github works to work on changes.