Skip to content

Possible simplification of is_made_of_eight_digits_fast #32

Open

Description

@Kristine1975

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;

Activity

  1. lemire commented on Nov 12, 2020

    @lemire
    Member

    To be reviewed and assessed. Thanks.

  2. aqrit commented on Nov 12, 2020

    @aqrit

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions