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

Possible simplification of is_made_of_eight_digits_fast #32

Open
Kristine1975 opened this issue Nov 12, 2020 · 2 comments
Open

Possible simplification of is_made_of_eight_digits_fast #32

Kristine1975 opened this issue Nov 12, 2020 · 2 comments

Comments

@Kristine1975
Copy link

This function could be simplified a bit:

https://github.com/lemire/fast_float/blob/7eae925b51fd0f570ccd5c880c12e3e27a23b86f/include/fast_float/ascii_number.h#L27

replace its implementation with:

return ((val & 0xF0F0F0F0F0F0F0F0u) & (val + 0x0606060606060606u)) == 0x3030303030303030u;

@lemire
Copy link
Member

lemire commented Nov 12, 2020

To be reviewed and assessed. Thanks.

@aqrit
Copy link

aqrit commented Nov 12, 2020

From #28:
return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) & 0x8080808080808080));

The ! and & operations should become a test instruction on x86. So it should be the same speed as @Kristine1975 suggestion. The term val - 0x3030303030303030 is needed immediately after the check ... so calculating it during the check may save one instruction down the road.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants