MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FastMod

Function FastMod

src/bloom.cpp:252–254  ·  view source on GitHub ↗

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/

Source from the content-addressed store, hash-verified

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/
252static inline uint32_t FastMod(uint32_t x, size_t n) {
253 return ((uint64_t)x * (uint64_t)n) >> 32;
254}
255
256void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
257{

Callers 2

insertMethod · 0.85
containsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected