Skip to content

Commit 908378a

Browse files
RichardWeiYangakpm00
authored andcommitted
maple_tree: simplify mas_push_node()
When count is not 0, we know head is valid. So we can put the assignment in if (count) instead of checking the head pointer again. Also count represents current total, we can assign the new total by increasing the count by one. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Wei Yang <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: Sidhartha Kumar <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4223dd9 commit 908378a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/maple_tree.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,19 +1207,17 @@ static inline void mas_push_node(struct ma_state *mas, struct maple_node *used)
12071207

12081208
reuse->request_count = 0;
12091209
reuse->node_count = 0;
1210-
if (count && (head->node_count < MAPLE_ALLOC_SLOTS)) {
1211-
head->slot[head->node_count++] = reuse;
1212-
head->total++;
1213-
goto done;
1214-
}
1215-
1216-
reuse->total = 1;
1217-
if ((head) && !((unsigned long)head & 0x1)) {
1210+
if (count) {
1211+
if (head->node_count < MAPLE_ALLOC_SLOTS) {
1212+
head->slot[head->node_count++] = reuse;
1213+
head->total++;
1214+
goto done;
1215+
}
12181216
reuse->slot[0] = head;
12191217
reuse->node_count = 1;
1220-
reuse->total += head->total;
12211218
}
12221219

1220+
reuse->total = count + 1;
12231221
mas->alloc = reuse;
12241222
done:
12251223
if (requested > 1)

0 commit comments

Comments
 (0)