aboutsummaryrefslogtreecommitdiff
path: root/src/bloom.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-04-24 18:37:29 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-04-28 14:56:32 +0200
commit1953c40aa9589a03035fd294f3ba3549374a4826 (patch)
tree5b8d6f7d7dbdb8852642339d54050693626d277b /src/bloom.h
parentaa62b68745ef43ca135fdffbd886818221e85731 (diff)
downloadbitcoin-1953c40aa9589a03035fd294f3ba3549374a4826.tar.xz
More efficient bitsliced rolling Bloom filter
This patch changes the implementation from one that stores 16 2-bit integers in one uint32_t's, to one that stores the first bit of 64 2-bit integers in one uint64_t and the second bit in another. This allows for 450x faster refreshing and 2.2x faster average speed.
Diffstat (limited to 'src/bloom.h')
-rw-r--r--src/bloom.h13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/bloom.h b/src/bloom.h
index b0ad8b875d..ad6de625d8 100644
--- a/src/bloom.h
+++ b/src/bloom.h
@@ -135,20 +135,9 @@ private:
int nEntriesPerGeneration;
int nEntriesThisGeneration;
int nGeneration;
- std::vector<uint32_t> data;
+ std::vector<uint64_t> data;
unsigned int nTweak;
int nHashFuncs;
-
- unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
-
- inline int get(uint32_t position) const {
- return (data[(position >> 4) % data.size()] >> (2 * (position & 0xF))) & 0x3;
- }
-
- inline void put(uint32_t position, uint32_t val) {
- uint32_t& cell = data[(position >> 4) % data.size()];
- cell = (cell & ~(((uint32_t)3) << (2 * (position & 0xF)))) | (val << (2 * (position & 0xF)));
- }
};
#endif // BITCOIN_BLOOM_H