A different namehash that works better for file naming format in dirbench.

I'm sure it fails for some other naming format..
上级 6bf61f8d
...@@ -696,8 +696,14 @@ u64 ...@@ -696,8 +696,14 @@ u64
namehash(const strbuf<DIRSIZ> &n) namehash(const strbuf<DIRSIZ> &n)
{ {
u64 h = 0; u64 h = 0;
for (int i = 0; i < DIRSIZ && n._buf[i]; i++) for (int i = 0; i < DIRSIZ && n._buf[i]; i++) {
h = ((h << 8) ^ n._buf[i]) % 0xdeadbeef; u64 c = n._buf[i];
// Lifted from dcache.h in Linux v3.3
h = (h + (c << 4) + (c >> 4)) * 11;
// XXX(sbw) this doesn't seem to do well with the names
// in dirbench (the low-order bits get clumped).
// h = ((h << 8) ^ c) % 0xdeadbeef;
}
return h; return h;
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论