maple_tree: refine mab_calc_split function
authorVernon Yang <vernon2gm@gmail.com>
Wed, 21 Dec 2022 06:00:58 +0000 (14:00 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 19 Jan 2023 01:12:47 +0000 (17:12 -0800)
Invert the conditional judgment of the mid_split, to focus the return
statement in the last statement, which is easier to understand and for
better readability.

Link: https://lkml.kernel.org/r/20221221060058.609003-8-vernon2gm@gmail.com
Signed-off-by: Vernon Yang <vernon2gm@gmail.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c

index d4554c1..94f0053 100644 (file)
@@ -1882,10 +1882,9 @@ static inline int mab_calc_split(struct ma_state *mas,
 
        /* Avoid ending a node on a NULL entry */
        split = mab_no_null_split(bn, split, slot_count);
-       if (!(*mid_split))
-               return split;
 
-       *mid_split = mab_no_null_split(bn, *mid_split, slot_count);
+       if (unlikely(*mid_split))
+               *mid_split = mab_no_null_split(bn, *mid_split, slot_count);
 
        return split;
 }