Thanks again for replying to my e-mail.
This PR holds the following changes:
In the bitmatrix the empty columns have been made redundant by a slight reorganization of the search algorithm. Directly after the mask is applied, the check for a match is run, rather than after the shift operation. This holds the advantage that an adapter of 64 can always be fit in one word, regardless of how many individual pieces are needed due to the error rate.
The value of 64 is hardcoded in one place and made available as a variable. This is used in tests.
The SHIFT-OR algorithm was changed to SHIFT-AND for the following reasons:
SHIFT-OR does not have an advantage over SHIFT-AND. The zeroes that are shifted an are of no value as there are multiple words in one machine word and there needs to be a mask anyway to set the correct bits.
SHIFT-AND allows for a simpler check if the word is found. (A simple bitwise AND and non-zero check).
SHIFT-AND is easier to understand, SHIFT-OR is just a clever implementation detail which only works for one word per machine word.
I also have SHIFT-AND in this other program I work on (sequali) and some insights might be transferred in the future when applicable.
I benchmarked the change and it seems to be consistently (very slightly) faster on my laptop (while on battery, not the best platform, I know), which I contribute to the simpler check inside the loop. At least it is certainly not slower.
Thanks again for replying to my e-mail. This PR holds the following changes:
I benchmarked the change and it seems to be consistently (very slightly) faster on my laptop (while on battery, not the best platform, I know), which I contribute to the simpler check inside the loop. At least it is certainly not slower.