aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-04-11 15:12:59 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-04-11 15:13:23 +0200
commit8562179612ae8bc80b1c21cd3545e00d9cbdd375 (patch)
tree35eaab6eca5deebc38ee2232e4bbfb57c6497864 /src
parent9c749d608fbac034cd19d02c7a026ecce0fe154d (diff)
parentb1b9c762623c392ac665ecdc315e1d2073eaac43 (diff)
downloadbitcoin-8562179612ae8bc80b1c21cd3545e00d9cbdd375.tar.xz
Merge pull request #3912
b1b9c76 Fix bloom filter not to use bit_mask (peryaudo)
Diffstat (limited to 'src')
-rw-r--r--src/bloom.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/bloom.cpp b/src/bloom.cpp
index cbb8cf4a82..1bfcbd406f 100644
--- a/src/bloom.cpp
+++ b/src/bloom.cpp
@@ -15,8 +15,6 @@
using namespace std;
-static const unsigned char bit_mask[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
-
CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweakIn, unsigned char nFlagsIn) :
// The ideal size for a bloom filter with a given number of elements and false positive rate is:
// - nElements * log(fp rate) / ln(2)^2
@@ -47,7 +45,7 @@ void CBloomFilter::insert(const vector<unsigned char>& vKey)
{
unsigned int nIndex = Hash(i, vKey);
// Sets bit nIndex of vData
- vData[nIndex >> 3] |= bit_mask[7 & nIndex];
+ vData[nIndex >> 3] |= (1 << (7 & nIndex));
}
isEmpty = false;
}
@@ -76,7 +74,7 @@ bool CBloomFilter::contains(const vector<unsigned char>& vKey) const
{
unsigned int nIndex = Hash(i, vKey);
// Checks bit nIndex of vData
- if (!(vData[nIndex >> 3] & bit_mask[7 & nIndex]))
+ if (!(vData[nIndex >> 3] & (1 << (7 & nIndex))))
return false;
}
return true;