Skip to content
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

Text to integer fast path for small integers? #151

Open
oscbyspro opened this issue Dec 16, 2024 · 1 comment
Open

Text to integer fast path for small integers? #151

oscbyspro opened this issue Dec 16, 2024 · 1 comment
Labels
brrr such code, much wow

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Dec 16, 2024

I wrote some code for a comment on the forums. In doing so, I noticed two things:

  1. Parsing up to the first invalid character without failing entirely by returning nil might be useful.
  2. I may speed up small integer decoding by removing the arbitrary precision overhead for types that fit in one word.

This issue tracks the 2nd point. I'll want to measure it, but it should be a simple improvement.

@oscbyspro oscbyspro added the brrr such code, much wow label Dec 16, 2024
@oscbyspro
Copy link
Owner Author

oscbyspro commented Dec 16, 2024

So this is a bit silly. Decoding an unsigned machine word with wrapping behavior is about 50% faster than decoding with error handling. The current arbitrary precision algorithm uses the wrapping version internally, so it ends up being about the same speed as a naive small integer algorithm with error handling. The former gets away with wrapping behavior because of its chunking strategy. Perhaps I should do something similar in the small integer algorithm? Hm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brrr such code, much wow
Projects
None yet
Development

No branches or pull requests

1 participant