提交 9de4be61 创建 作者: David Benjamin's avatar David Benjamin

radix: Refactor index computation a little

Slightly easier to read.
上级 415644db
#include "crange_arch.hh"
#include "radix.hh"
static u64
index(u64 key, u32 level)
{
u64 idx = key >> (bits_per_level * level);
idx &= (1 << bits_per_level) - 1;
return idx;
}
// Returns the level we stopped at.
template<class CB>
u32
......@@ -25,9 +33,7 @@ descend(u64 key, markptr<void> *n, u32 level, CB cb, bool create)
radix_node *rn = (radix_node*) v;
u64 idx = key >> (bits_per_level * level);
idx &= (1<<bits_per_level)-1;
markptr<void> *vptr = &rn->ptr[idx];
markptr<void> *vptr = &rn->ptr[index(key, level)];
if (level == 0) {
cb(vptr);
return level;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论