diff mbox series

maple_tree: root node could be handled by !p_slot too

Message ID 20240913063128.27391-1-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series maple_tree: root node could be handled by !p_slot too | expand

Commit Message

Wei Yang Sept. 13, 2024, 6:31 a.m. UTC
For a root node, mte_parent_slot() return 0, this exactly fits the
following !p_slot check.

So we can remove the special handling for root node.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
 lib/maple_tree.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Liam R. Howlett Sept. 13, 2024, 2:17 p.m. UTC | #1
* Wei Yang <richard.weiyang@gmail.com> [240913 02:31]:
> For a root node, mte_parent_slot() return 0, this exactly fits the
> following !p_slot check.

This sounds right, I will have to look deeper at it though.

Thanks,
Liam

> 
> So we can remove the special handling for root node.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> ---
>  lib/maple_tree.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 85bd651e7770..b5dde94cc7a9 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -2100,9 +2100,7 @@ static inline bool mas_prev_sibling(struct ma_state *mas)
>  {
>  	unsigned int p_slot = mte_parent_slot(mas->node);
>  
> -	if (mte_is_root(mas->node))
> -		return false;
> -
> +	/* For root node, p_slot is set to 0 by mte_parent_slot(). */
>  	if (!p_slot)
>  		return false;
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 85bd651e7770..b5dde94cc7a9 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2100,9 +2100,7 @@  static inline bool mas_prev_sibling(struct ma_state *mas)
 {
 	unsigned int p_slot = mte_parent_slot(mas->node);
 
-	if (mte_is_root(mas->node))
-		return false;
-
+	/* For root node, p_slot is set to 0 by mte_parent_slot(). */
 	if (!p_slot)
 		return false;