[bitcoin/bitcoin] Improve CRollingBloomFilter performance: replace modulus with FastMod (#13176)

Empact commented on this pull request.

> @@ -245,6 +245,14 @@ static inline uint32_t RollingBloomHash(unsigned int nHashNum, uint32_t nTweak,
return MurmurHash3(nHashNum * 0xFBA4C795 + nTweak, vDataToHash);

+// 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/
+static inline uint32_t FastMod(uint32_t x, size_t n) {

nit: Could replace `inline` with `constexpr`

This post was last modified on May 7, 2018, 7:21 pm