Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/BloomFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ bool BloomFilter::contains(const string &element) {

static unsigned int djb2Hash(const string &text) {
unsigned int hash = 5381;
for (const char &iterator : text) {
hash = ((hash << 5) + hash) + iterator;
for (auto ch : text) {
hash = ((hash << 5) + hash) + static_cast<unsigned char>(ch);
}
return hash;
}

static unsigned int sdbmHash(const string &text) {
unsigned int hash = 0;
for (const char &iterator : text) {
hash = iterator + ((hash << 6) + (hash << 16) - hash);
for (auto ch : text) {
hash = static_cast<unsigned char>(ch) + ((hash << 6) + (hash << 16) - hash);
}
return hash;
}
Expand Down Expand Up @@ -151,4 +151,4 @@ static vector<BlockType> readVectorFromStream(BinaryInputStream &in) {

size_t BloomFilter::getBitCount() const {
return bitCount;
}
}