A replacement for x % n. This assumes that x and n are 32bit integers, and x is a uniformly random distributed 32bit value which should be the case for a good hash. See https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
| 250 | // which should be the case for a good hash. |
| 251 | // See https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ |
| 252 | static inline uint32_t FastMod(uint32_t x, size_t n) { |
| 253 | return ((uint64_t)x * (uint64_t)n) >> 32; |
| 254 | } |
| 255 | |
| 256 | void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey) |
| 257 | { |