static inline bool _mas_awalk(struct ma_state *mas, unsigned long size)
{
enum maple_type type = mte_node_type(mas->node);
- unsigned long pivot, min, gap;
+ unsigned long pivot, min, gap = 0;
unsigned char slot = 0, pivot_cnt = mt_pivots[type];
bool found = false;
goto next_slot;
if (ma_is_leaf(type)) {
- if (!mt_is_empty(mas_get_rcu_slot(mas, slot)))
- goto next_slot;
-
- gap = pivot - mas->index;
- if (!gap) // No entry, pivot = index.
- gap = 1;
-
- if (mas->last + size < pivot - gap) { // upper bound
- mas_set_err(mas, -EBUSY);
- return true;
- }
- if (mas->last < pivot - gap) // gap check
- break;
+ gap = 0;
+ if (mt_is_empty(mas_get_rcu_slot(mas, slot)))
+ gap = min(pivot, mas->last) -
+ max(mas->index, min) + 1;
} else {
gap = mte_get_gap(mas->node, slot);
}
+next_slot:
if (gap >= size) {
if (ma_is_leaf(type)) {
found = true;
break;
}
}
-next_slot:
min = pivot + 1;
if (mas->last < min) {
mas_set_err(mas, -EBUSY);