]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: awalk reduce again.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 18 Jul 2020 00:28:49 +0000 (20:28 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:05:35 +0000 (15:05 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 1f4ba438dbefce895ab9015e257c59c55f17764d..0c56767f5591e7de66f3c4c5465e2af560c7127f 100644 (file)
@@ -3364,6 +3364,14 @@ void *mas_prev(struct ma_state *mas, unsigned long min)
 }
 EXPORT_SYMBOL_GPL(mas_prev);
 
+static inline unsigned long _mas_rev_awalk_min(struct ma_state *mas,
+                                              unsigned char slot,
+                                              enum maple_type type)
+{
+       if (!slot)
+               return mas->min;
+       return _mte_get_pivot(mas->node, slot - 1, type) + 1;
+}
 static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
 {
        enum maple_type type;
@@ -3384,11 +3392,7 @@ static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
                do {
                        void *entry = NULL;
 
-                       if (!i)
-                               min = mas->min;
-                       else
-                               min = _mte_get_pivot(mas->node, i - 1,
-                                               type) + 1;
+                       min = _mas_rev_awalk_min(mas, i, type);
 
                        /* last is below this range */
                        if (mas->last < min)
@@ -3431,12 +3435,7 @@ next_slot:
        default:
 
                do {
-                       if (!i)
-                               min = mas->min;
-                       else
-                               min = _mte_get_pivot(mas->node, i - 1,
-                                               type) + 1;
-
+                       min = _mas_rev_awalk_min(mas, i, type);
 
                        /* last is too little for this range */
                        if (mas->last < min)