]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: mas_leaf_max_gap optimizations for ma_pivots
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 23 Sep 2020 02:41:10 +0000 (22:41 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:28 +0000 (12:30 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 66c539b4c815c8382abb137bddb9023ce3a40c09..9d52bf8fd757ffa5d68815a58df50a82142e01cf 100644 (file)
@@ -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;