]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Use a variable for b_node->b_end
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 7 Dec 2020 00:55:55 +0000 (19:55 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:33 +0000 (12:33 -0500)
Makes cleaner code and less dereferences

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 653378434c0e851dee7a793d0a164aac02ec2ccc..b33dcfec378996cea61e0c74a897159f26a4fca5 100644 (file)
@@ -1500,7 +1500,8 @@ static inline int mab_calc_split(struct ma_state *mas,
                                 struct maple_big_node *b_node,
                                 unsigned char *mid_split)
 {
-       int split = b_node->b_end / 2; // Assume equal split.
+       unsigned char b_end = b_node->b_end;
+       int split = b_end / 2; // Assume equal split.
        unsigned char min, slot_count = mt_slots[b_node->type];
 
        if (unlikely((mas->mas_flags & MA_STATE_BULK))) {
@@ -1508,9 +1509,9 @@ static inline int mab_calc_split(struct ma_state *mas,
                if (ma_is_leaf(b_node->type))
                        min = 2;
                else
-                       return b_node->b_end - mt_min_slots[b_node->type];
+                       return b_end - mt_min_slots[b_node->type];
 
-               split = b_node->b_end - min;
+               split = b_end - min;
                mas->mas_flags |= MA_STATE_REBALANCE;
                if (!b_node->slot[split])
                        split--;
@@ -1518,7 +1519,7 @@ static inline int mab_calc_split(struct ma_state *mas,
        }
 
        if (unlikely(mab_middle_node(b_node, split, slot_count))) {
-               split = b_node->b_end / 3;
+               split = b_end / 3;
                *mid_split = split * 2;
        } else {
                min = mt_min_slots[b_node->type];
@@ -1529,8 +1530,7 @@ static inline int mab_calc_split(struct ma_state *mas,
                 * NOTE: mt_min_slots is 1 based, b_end and split are zero.
                 */
                while (((b_node->pivot[split] - b_node->min) < slot_count - 1) &&
-                      (split < slot_count - 1) &&
-                      (b_node->b_end - split > min))
+                      (split < slot_count - 1) && (b_end - split > min))
                        split++;
        }