-
Notifications
You must be signed in to change notification settings - Fork 99
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
Feature request: Returning number of characters processed in ryu_parse #147
Comments
I propose that ryu_parse provides a drop-in replacement for |
@expnkx thanks for suggesting your library, but I only need low-level parsing primitives for a library I'm working on. I want the number parsing dependency for my library to be as small as possible, with |
@expnkx I agree the API for |
@expnkx The purpose of this issue is to improve this project, not to promote your library. |
@expnkx I don't mind your suggestions for a better API within the scope of this project. What I do mind is your insistance to use your library instead of this one. If you think nobody should be using this library, then please go away - you're not helping. This is an issue tracker specific to this project, not your personal soap box. |
@ecorm, I'm not sure I follow. s2d_n is supposed to consume the entire input. I can imagine an API that consumes as much as possible and leaves it to the caller to check if the entire input is consumed, although I think it's a bit risky if there's a mismatch between the format expected here and the format expected one level up. |
@ulfjack Consuming as much as possible is exactly what If you think returning the number of characters consumed would somehow hurt the performance, or you want to avoiding breaking the existing API, then I'd propose extra parsing functions that do return the number of characters consumed. It turns out after all that I need to find the number boundary anyway within my JSON document, so I longer need the number of bytes consumed. However, I suggest that you leave this feature request open for a while to see if others might be interested in it. |
Hi, I tweaked the s2d and s2f implementation for my needs, which involves returning the number of characters processed. I also removed the status code, and replaced them by asserts, which makes these functions unsafe, but I'd be happy to create a PR which only returns the number of character processed if you're interested. |
ryu_parse does not return the number of characters processed, so we are forced to tokenize the input before feeding it to
s2d
.s2d
already knows when to stop consuming the input at the first non-number character, so there ends up being a duplication of effort and parsing a list of numbers is slower than it should be.Both std::strtod and std::from_chars return a pointer to the first character not matching the number pattern. ryu_parse should do the same.
With this proposal, the
INPUT_TOO_LONG
status code would become obsolete.The text was updated successfully, but these errors were encountered: