From e03a8f759b0d60f0b82d683de959edc3f68dbc67 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 4 Sep 2020 16:23:23 -0400 Subject: [PATCH] maple_tree: mas_data_end reduction #2 Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 153b5dfd6e91..74354f7f0e8c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1633,8 +1633,9 @@ static inline struct maple_enode *mte_node_or_none(struct maple_enode *enode) */ static inline void mast_topiary(struct maple_subtree_state *mast) { - unsigned char l_slot, r_slot, slot, end; + unsigned char l_slot, r_slot, slot; unsigned long l_index, range_min, range_max; + struct maple_enode *child; // The left node is consumed, so add to the free list. l_index = mast->orig_l->index; @@ -1655,9 +1656,13 @@ static inline void mast_topiary(struct maple_subtree_state *mast) return; /* Now destroy l_slot + 1 -> end and 0 -> r_slot - 1 */ - end = mas_data_end(mast->orig_l); - for (slot = l_slot + 1; slot <= end; slot++) - mat_add(mast->destroy, mas_get_slot(mast->orig_l, slot)); + slot = l_slot + 1; + while (slot < mt_slot_count(mast->orig_l->node)) { + child = mas_get_slot(mast->orig_l, slot++); + if (!child) + break; + mat_add(mast->destroy, child); + } for (slot = 0; slot < r_slot; slot++) mat_add(mast->destroy, mas_get_slot(mast->orig_r, slot)); @@ -2759,7 +2764,6 @@ static inline bool mas_wr_walk(struct ma_state *mas, unsigned long *range_min, type = mte_node_type(mas->node); mas->depth++; - end = mas_data_end(mas); if (unlikely(!mas_node_walk(mas, type, range_min, range_max))) return false; @@ -2769,6 +2773,7 @@ static inline bool mas_wr_walk(struct ma_state *mas, unsigned long *range_min, if (ma_is_leaf(type)) return true; + end = mas_data_end(mas); if (end <= mt_min_slots[type]) mas_cnt_empty(mas); else if (end >= mt_slots[type] - 2) -- 2.50.1