Skip to content

Alternative to countTrailingZeros for bitmap iteration #424

@sjakobi

Description

@sjakobi

unionArrayBy and intersectionArrayBy currently use countTrailingZeros to detect set bits in bitmaps.

Alternatively, lowest set bits can be isolated like this:

isolateLowestSetBit :: Word -> Word
isolateLowestSetBit x = x .&. negate x

(Explanation in https://stackoverflow.com/a/12250963/1013393)

The latter technique is already being used in submapBitmapIndexed to create the initial bit mask.

It would be good to consistently use only one technique, ideally by refactoring this pattern into a proper function like isolateLowestSetBit.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions