Skip to content

Commit 3f05fcd

Browse files
Peng Zhangakpm00
authored andcommitted
maple_tree: avoid ascending when mas->min is also the parent's minimum
When the child node is the first child of its parent node, mas->min does not need to be updated. This can reduce the number of ascending times in some cases. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peng Zhang <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: Dan Carpenter <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2e783f0 commit 3f05fcd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/maple_tree.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,14 +1088,16 @@ static int mas_ascend(struct ma_state *mas)
10881088
return 0;
10891089
}
10901090

1091-
if (!mas->min)
1091+
min = 0;
1092+
max = ULONG_MAX;
1093+
if (!mas->offset) {
1094+
min = mas->min;
10921095
set_min = true;
1096+
}
10931097

10941098
if (mas->max == ULONG_MAX)
10951099
set_max = true;
10961100

1097-
min = 0;
1098-
max = ULONG_MAX;
10991101
do {
11001102
p_enode = a_enode;
11011103
a_type = mas_parent_type(mas, p_enode);

0 commit comments

Comments
 (0)