]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
multi_src_setup(): Add wr_mas optimisation for appending
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 25 Sep 2025 02:52:54 +0000 (22:52 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 25 Sep 2025 02:52:54 +0000 (22:52 -0400)
Use already available data, when possible

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

index 4c8fe5d3889f287d41761b31efe31e5beb8ad351..1bf4e7524daf716f10362d4a99abe1a3bae363f6 100644 (file)
@@ -2338,7 +2338,7 @@ void node_finalise(struct maple_node *node, enum maple_type mt, unsigned char en
                ma_set_meta(node, mt, gap_slot, end - 1);
 }
 
-static inline void append_node_cp(struct maple_copy *cp,
+static inline void append_mas_cp(struct maple_copy *cp,
        struct ma_state *mas, unsigned char start, unsigned char end)
 {
        struct maple_node *node;
@@ -2348,7 +2348,6 @@ static inline void append_node_cp(struct maple_copy *cp,
        count = cp->s_count;
        node = mas_mn(mas);
        mt = mte_node_type(mas->node);
-
        cp->src[count].node = node;
        cp->src[count].mt = mt;
        if (mas->end <= end)
@@ -2361,6 +2360,24 @@ static inline void append_node_cp(struct maple_copy *cp,
        cp->s_count++;
 }
 
+static inline void append_wr_mas_cp(struct maple_copy *cp,
+       struct ma_wr_state *wr_mas, unsigned char start, unsigned char end)
+{
+       unsigned char count;
+
+       count = cp->s_count;
+       cp->src[count].node = wr_mas->node;
+       cp->src[count].mt = wr_mas->type;
+       if (wr_mas->mas->end <= end)
+               cp->src[count].max = wr_mas->mas->max;
+       else
+               cp->src[count].max = wr_mas->pivots[end];
+
+       cp->src[count].start = start;
+       cp->src[count].end = end;
+       cp->s_count++;
+}
+
 static inline void cp_leaf_init(struct maple_copy *cp,
                struct ma_state *mas, struct ma_wr_state *l_wr_mas,
                struct ma_wr_state *r_wr_mas)
@@ -2651,13 +2668,13 @@ void multi_src_setup(struct maple_copy *cp, struct ma_wr_state *l_wr_mas,
 {
        cp->s_count = 0;
        if (sib->end && sib->max < l_wr_mas->mas->min)
-               append_node_cp(cp, sib, 0, sib->end);
+               append_mas_cp(cp, sib, 0, sib->end);
 
        /* Copy left 0 - offset */
        if (l_wr_mas->mas->offset) {
                unsigned char off = l_wr_mas->mas->offset - 1;
 
-               append_node_cp(cp, l_wr_mas->mas, 0, off);
+               append_wr_mas_cp(cp, l_wr_mas, 0, off);
                cp->src[cp->s_count - 1].max = cp->min - 1;
        }
 
@@ -2665,11 +2682,11 @@ void multi_src_setup(struct maple_copy *cp, struct ma_wr_state *l_wr_mas,
 
        /* Copy right either from offset or offset + 1 pending on r_max */
        if (r_wr_mas->mas->end != r_wr_mas->offset_end)
-               append_node_cp(cp, r_wr_mas->mas, r_wr_mas->offset_end + 1,
+               append_wr_mas_cp(cp, r_wr_mas, r_wr_mas->offset_end + 1,
                               r_wr_mas->mas->end);
 
        if (sib->end && sib->min > r_wr_mas->mas->max)
-               append_node_cp(cp, sib, 0, sib->end);
+               append_mas_cp(cp, sib, 0, sib->end);
 }
 
 static inline