[Maple Tree 20220301] Report of condition before ma_gaps() function in lib/maple_tree.c

JaeJoon Jung rgbi3307 at gmail.com
Fri Mar 4 05:08:32 PST 2022


Hi, Liam.

By the switch-case statement in the ma_gaps() function,
each type is classified and the code is optimized by the compiler.
So, there is no need for an if condition that determines nodes by type
before calling this function.
Please check my corrections below:

@@ -4858,10 +4858,7 @@ static bool mas_rev_awalk(struct ma_state *mas,
unsigned long size)

        pivots = ma_pivots(node, type);
        slots = ma_slots(node, type);
-       if (ma_is_leaf(type))
-               gaps = NULL;
-       else
-               gaps = ma_gaps(node, type);
+       gaps = ma_gaps(node, type);

        offset = mas->offset;
        min = mas_safe_min(mas, pivots, offset);


@@ -4942,8 +4939,7 @@ static inline bool mas_anode_descend(struct
ma_state *mas, unsigned long size)
                return true;
        }

-       if (!ma_is_leaf(type))
-               gaps = ma_gaps(mte_to_node(mas->node), type);
+       gaps = ma_gaps(mte_to_node(mas->node), type);

        offset = mas->offset;
        count = mt_slots[type];


@@ -6703,8 +6698,7 @@ void mas_validate_gaps(struct ma_state *mas)
                goto counted;
        }

-       if (!mte_is_leaf(mte))
-               gaps = ma_gaps(mte_to_node(mte), mte_node_type(mte));
+       gaps = ma_gaps(mte_to_node(mte), mte_node_type(mte));

        for (i = 0; i < mt_slot_count(mte); i++) {
                p_end = mas_logical_pivot(mas, pivots, i, mte_node_type(mte));

Best regards,
JaeJoon Jung.



More information about the maple-tree mailing list