fast_float
fast_float copied to clipboard
Possible simplification of is_made_of_eight_digits_fast
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;
To be reviewed and assessed. Thanks.
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.