static inline unsigned long mas_leaf_max_gap(struct ma_state *mas)
{
enum maple_type mt = mte_node_type(mas->node);
+ unsigned long *pivots = ma_pivots(mas_mn(mas), mt);
+ void **slots = ma_slots(mas_mn(mas), mt);
+ unsigned long gap = 0, max_gap = 0;
unsigned long pstart, pend;
- unsigned long max_gap = 0;
- unsigned long gap = 0;
- void *entry = NULL;
int i;
- void **slots = ma_slots(mte_to_node(mas->node), mt);
if (ma_is_dense(mt)) {
for (i = 0; i < mt_slot_count(mas->node); i++) {
- entry = slots[i];
- if (entry) {
+ if (mas_slot_protected(mas, slots, i)) {
if (gap > max_gap)
max_gap = gap;
gap = 0;
pstart = mas->min;
for (i = 0; i < mt_slots[mt]; i++) {
- pend = mas_safe_pivot(mas, i);
+ pend = _mas_safe_pivot(mas, pivots, i, mt);
if (!pend && i)
pend = mas->max;
- gap = pend - pstart + 1;
- entry = slots[i];
- if (entry)
+ if (mas_slot_protected(mas, slots, i))
goto next;
+ gap = pend - pstart + 1;
if (gap > max_gap)
max_gap = gap;