Skip to content

Commit

Permalink
Improve default strhash function
Browse files Browse the repository at this point in the history
Summary:
from kevinweil@gmail.com in opensource

Test Plan:
compile

DiffCamp Revision: 109728
Reviewed By: jsong
CC: agiardullo, jsong, groys, scribe-dev@lists
Revert Plan:
OK

git-svn-id: svn+ssh://tubbs/svnapps/fbomb/trunk/fbcode/scribe@26719 2248de34-8caa-4a3c-bc55-5e52d9d7b73a
  • Loading branch information
groys authored and groys committed May 17, 2010
1 parent e3263e8 commit 26dbdd5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/env_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ class integerhash {
class strhash {
public:
static uint32_t hash32(const char *s) {
return 0;
// Use the djb2 hash (http://www.cse.yorku.ca/~oz/hash.html)
if (s == NULL) {
return 0;
}
uint32_t hash = 5381;
int c;
while ((c = *s++)) {
hash = ((hash << 5) + hash) + c; // hash * 33 + c
}
return hash;
}
};

Expand Down

0 comments on commit 26dbdd5

Please sign in to comment.