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

Store radix_entry in radix_iterator2 instead of void*

Still assuming that the leaf is at level 0, but we're getting there.
上级 0e9d895b
......@@ -221,7 +221,7 @@ struct radix_iterator2 {
// and is radix_elem. The rest are radix_node. For now we assume all
// leaves are at level 0. Later we'll steal a bit for them. The root
// is path_[radix_levels].
void *path_[radix_levels+1];
radix_entry path_[radix_levels+1];
radix_iterator2(const radix* r, u64 k);
......@@ -230,9 +230,9 @@ struct radix_iterator2 {
return *this;
}
radix_elem* operator*() {
return (radix_elem*)path_[0];
return path_[0].elem();
}
radix_node* node(u32 level) { return (radix_node*)path_[level]; }
radix_node* node(u32 level) { return path_[level].node(); }
// Compare equality on just the key.
bool operator==(const radix_iterator2 &other) {
......
......@@ -187,7 +187,7 @@ radix_iterator2::radix_iterator2(const radix* r, u64 k)
: r_(r), k_(k) {
dprintf("%p: Made iterator with k = %lu\n", r_, k_);
if (k_ != ~0ULL) {
path_[radix_levels] = (void*)r_->root_.load().ptr();
path_[radix_levels] = r_->root_.load();
if (!find_first_leaf(radix_levels - 1))
k_ = ~0ULL;
}
......@@ -220,8 +220,8 @@ radix_iterator2::find_first_leaf(u32 level)
{
// Find the first non-empty node after k_ on this level.
for (u32 idx = index(k_, level); idx < (1<<bits_per_level); idx++) {
void *next = (void*) node(level+1)->child[idx].load().ptr();
if (next != nullptr) {
radix_entry next = node(level+1)->child[idx].load();
if (!next.is_null()) {
if (index(k_, level) != idx) {
// We had to advance; clear everything this level and under
// and set this one.
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论