diff mbox series

[3/4] maple_tree: simplify mas_push_node()

Message ID 20240924123954.18933-4-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series cleanup maple_alloc related functions | expand

Commit Message

Wei Yang Sept. 24, 2024, 12:39 p.m. UTC
When count is not 0, we know head is valid. So we can put the assignment
in if(count) instead of check head again.

Also count represents current total, we can assign the new total by
increasing count at last.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 lib/maple_tree.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index c1fb67540cc9..1cbc5f7ca40d 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1192,19 +1192,17 @@  static inline void mas_push_node(struct ma_state *mas, struct maple_node *used)
 
 	reuse->request_count = 0;
 	reuse->node_count = 0;
-	if (count && (head->node_count < MAPLE_ALLOC_SLOTS)) {
-		head->slot[head->node_count++] = reuse;
-		head->total++;
-		goto done;
-	}
-
-	reuse->total = 1;
-	if ((head) && !((unsigned long)head & 0x1)) {
+	if (count) {
+		if (head->node_count < MAPLE_ALLOC_SLOTS) {
+			head->slot[head->node_count++] = reuse;
+			head->total++;
+			goto done;
+		}
 		reuse->slot[0] = head;
 		reuse->node_count = 1;
-		reuse->total += head->total;
 	}
 
+	reuse->total = count + 1;
 	mas->alloc = reuse;
 done:
 	if (requested > 1)