Skip to content

Commit 5f2c696

Browse files
committed
Shift before truncating block starts in binary_fuse8_populate (fixes #80)
The cast to uint32_t was applied to i * size before the shift, so the product wrapped above 2^32 (from about 8.4M keys) and block starts landed in low positions, slowing populate several fold. Match the fuse16 code.
1 parent 3e10fb1 commit 5f2c696

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎include/binaryfusefilter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static inline bool binary_fuse8_populate(uint64_t *keys, uint32_t size,
332332
for (uint32_t i = 0; i < block; i++) {
333333
// important : i * size would overflow as a 32-bit number in some
334334
// cases.
335-
startPos[i] = (uint32_t)((uint64_t)i * size) >> blockBits;
335+
startPos[i] = (uint32_t)(((uint64_t)i * size) >> blockBits);
336336
}
337337

338338
uint64_t maskblock = block - 1;

0 commit comments

Comments
 (0)