]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Make mas_max_gap() only set gaps when necessary
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 11 Dec 2020 02:53:08 +0000 (21:53 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:38 +0000 (12:33 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 7a1d2937b4a2cb0fd2c06266905c0fd8c2670b10..21e40d39095127902ceda5f4e99161db60e28b0f 100644 (file)
@@ -1169,16 +1169,16 @@ static inline unsigned long mas_max_gap(struct ma_state *mas)
        enum maple_type mt;
        struct maple_node *node;
 
-       if (mte_is_leaf(mas->node))
+       mt = mte_node_type(mas->node);
+       if (ma_is_leaf(mt))
                return mas_leaf_max_gap(mas);
 
-       mt = mte_node_type(mas->node);
-       node = mte_to_node(mas->node);
-       gaps = ma_gaps(node, mt);
+       node = mas_mn(mas);
        offset = ma_meta_gap(node, mt);
        if (offset == 15)
                return 0;
 
+       gaps = ma_gaps(node, mt);
        return gaps[offset];
 }
 
@@ -1240,7 +1240,8 @@ ascend:
 static inline void mas_update_gap(struct ma_state *mas)
 {
        unsigned char pslot;
-       unsigned long p_gap, max_gap = 0;
+       unsigned long p_gap;
+       unsigned long max_gap;
 
        if (!mt_is_alloc(mas->tree))
                return;