From 1ae507cf605bc4cc0810c71f25be54f784e8fde2 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 22 Sep 2020 22:41:10 -0400 Subject: [PATCH] maple_tree: mas_leaf_max_gap optimizations for ma_pivots Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 66c539b4c815..9d52bf8fd757 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1054,17 +1054,15 @@ static inline unsigned char mas_data_end(const struct ma_state *mas) 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; @@ -1079,15 +1077,14 @@ static inline unsigned long mas_leaf_max_gap(struct ma_state *mas) 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; -- 2.50.1