[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250626171918.17261-1-dev.jain@arm.com>
Date: Thu, 26 Jun 2025 22:49:17 +0530
From: Dev Jain <dev.jain@....com>
To: akpm@...ux-foundation.org,
Liam.Howlett@...cle.com
Cc: richard.weiyang@...il.com,
maple-tree@...ts.infradead.org,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Dev Jain <dev.jain@....com>
Subject: [PATCH 1/2] maple tree: Clean up mtree_range_walk()
The special casing for offset == 0 is being done because min will stay
mas->min in this case. So refactor the code to use the while loop for
setting the max and getting the corresponding offset, and only set the
min for offset > 0.
Signed-off-by: Dev Jain <dev.jain@....com>
---
lib/maple_tree.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 0e85e92c5375..6c89e6790fb5 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2770,13 +2770,8 @@ static inline void *mtree_range_walk(struct ma_state *mas)
end = ma_data_end(node, type, pivots, max);
prev_min = min;
prev_max = max;
- if (pivots[0] >= mas->index) {
- offset = 0;
- max = pivots[0];
- goto next;
- }
- offset = 1;
+ offset = 0;
while (offset < end) {
if (pivots[offset] >= mas->index) {
max = pivots[offset];
@@ -2784,9 +2779,9 @@ static inline void *mtree_range_walk(struct ma_state *mas)
}
offset++;
}
+ if (likely(offset))
+ min = pivots[offset - 1] + 1;
- min = pivots[offset - 1] + 1;
-next:
slots = ma_slots(node, type);
next = mt_slot(mas->tree, slots, offset);
if (unlikely(ma_dead_node(node)))
--
2.30.2
Powered by blists - more mailing lists