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, Redis and WebKit/Safari
Apache License 2.0
1.54k stars 132 forks source link

from_chars_advanced overload function taking parsed_number_string_t #249

Closed zejal closed 3 months ago

zejal commented 5 months ago

Idea is to split parsing from value computation adding a from_chars_advanced function taking result of parsing.

lemire commented 5 months ago

@zejal Can you motivate this change? Why is it beneficial?

zejal commented 5 months ago

This would allow someone (as I would like to do to use fast_float in existing code) to write an alternative string parser function that creates and populates the parsed_number_string_t and call added overloaded function. Of course the existing from_chars_advanced taking chars range and parsing options remains and called suggested added one.

Perhaps accepting this change implies to document a bit what the contents of parsed_number_string_t structure. In particular the integer and fraction bits ?

lemire commented 5 months ago

Perhaps accepting this change implies to document a bit what the contents of parsed_number_string_t structure. In particular the integer and fraction bits ?

Do you want to add some comments to the code so that this is clearer? No need to write very much, just enough so that people understand why the code is structured this way.

zejal commented 5 months ago

Thanks, added some comments, hope it helps.

lemire commented 5 months ago

I expect to merge once the test pass.

It should be part of the next release.

zejal commented 5 months ago

Sure, thanks a lot