]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Clean up mas_node_store() by using local var
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 30 Nov 2020 20:22:52 +0000 (15:22 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:29 +0000 (12:33 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 596b6eb7429dab099c8f50d8b94e9f1630d7976f..904fc63be1197dfce55d653873f6d131e2e9233a 100644 (file)
@@ -3170,7 +3170,7 @@ static inline bool mas_node_store(struct ma_state *mas, void *entry,
        unsigned char dst_offset, new_end = end;
        unsigned char offset, offset_end;
        struct maple_node reuse, *newnode;
-       unsigned char copy_size;
+       unsigned char copy_size, max_piv = mt_pivots[mt];
 
        offset = offset_end = mas->offset;
        if (mas->last == max) { // don't copy this offset
@@ -3232,7 +3232,7 @@ static inline bool mas_node_store(struct ma_state *mas, void *entry,
        }
 
        // Store the new entry and range end.
-       if (dst_offset < mt_pivots[mt])
+       if (dst_offset < max_piv)
                dst_pivots[dst_offset] = mas->last;
        dst_slots[dst_offset++] = entry;
 
@@ -3243,9 +3243,9 @@ static inline bool mas_node_store(struct ma_state *mas, void *entry,
        copy_size = end - offset_end + 1;
        memcpy(dst_slots + dst_offset, slots + offset_end,
               sizeof(void *) * copy_size);
-       if (dst_offset < mt_pivots[mt]) {
-               if (copy_size > mt_pivots[mt] - dst_offset)
-                       copy_size = mt_pivots[mt] - dst_offset;
+       if (dst_offset < max_piv) {
+               if (copy_size > max_piv - dst_offset)
+                       copy_size = max_piv - dst_offset;
                memcpy(dst_pivots + dst_offset, pivots + offset_end,
                       sizeof(unsigned long) * copy_size);
        }
@@ -3334,6 +3334,7 @@ static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite
        if (mas_is_err(mas))
                return NULL;
 
+
        if (mas_start(mas) || mas_is_none(mas) || mas->node == MAS_ROOT) {
                ret = ma_root_ptr(mas, entry, content, overwrite);
                if (mas_is_err(mas))