Skip to content

clearBit @Natural allocates more than necessary

The current definition is

clearBit x i  = x `xor` (bit i .&. x)

It seems that this implementation would allocate intermediate Naturals as the result the bit and (.&.) functions. It should be possible to avoid these allocations by using the underlying primitives such as bigNatClearBit#.

Edited by Simon Jakobi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information