enum maple_type type;
struct maple_node *next;
unsigned long pivot_cnt, pivot, max, min, i;
+ bool ret = true;
mas->node = mas_start(mas);
+ min = mas->min;
+ max = mas->max;
while (true) {
type = mt_node_type(mas->node);
pivot_cnt = mt_pivots[type];
- min = mas->min;
- max = mas->max;
- if (pivot_cnt) {
+ switch (type) {
+ default:
pivot = 0;
for (i = 0; i < pivot_cnt; i++) {
pivot = _ma_get_pivot(mas->node, i, type);
min = pivot;
}
- if (i == pivot_cnt - 1) {
- if (mas->index > pivot)
+ if ((i == pivot_cnt - 1) && (mas->index > pivot))
i++;
- }
- } else {
+
+ if (type < maple_range_16) // Leaf.
+ goto done;
+ break;
+
+ case maple_dense:
// Linear node.
i = mas->index - mas->min;
if (mas->min)
i--;
+ goto done;
+ break;
}
- ma_set_slot(mas, i);
- if (type < maple_range_16) // Leaf.
- return true;
-
next = _ma_get_rcu_slot(mas->node, i, type);
if (!next) // Not found.
- return type < maple_range_16;
+ goto done;
// Traverse.
mas->max = max;
mas->min = min;
mas->node = next;
}
+done:
+ ma_set_slot(mas, i);
+ return ret;
}
static inline void ma_insert(struct ma_state *mas, void *entry)