From 5f2c6969077639d3a35558009891d9ef74b40511 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 29 Oct 2026 21:32:02 -0400 Subject: [PATCH] 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. --- include/binaryfusefilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/binaryfusefilter.h b/include/binaryfusefilter.h index fef4b10..d949e0c 100644 --- a/include/binaryfusefilter.h +++ b/include/binaryfusefilter.h @@ -332,7 +332,7 @@ static inline bool binary_fuse8_populate(uint64_t *keys, uint32_t size, for (uint32_t i = 0; i < block; i++) { // important : i * size would overflow as a 32-bit number in some // cases. - startPos[i] = (uint32_t)((uint64_t)i * size) >> blockBits; + startPos[i] = (uint32_t)(((uint64_t)i * size) >> blockBits); } uint64_t maskblock = block - 1;