diff mbox series

[3/3] maple_tree: local variable 'count' is not necessary

Message ID 20240831001053.4751-3-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series [1/3] maple_tree: use ma_data_end() in mas_data_end() | expand

Commit Message

Wei Yang Aug. 31, 2024, 12:10 a.m. UTC
'count' is never changed after assignment and it looks a little
more direct to use mas->end to locate the offset.

Also ma_data_end() returns slot index instead of count.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 lib/maple_tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Liam R. Howlett Sept. 4, 2024, 12:42 a.m. UTC | #1
* Wei Yang <richard.weiyang@gmail.com> [240830 20:11]:
> 'count' is never changed after assignment and it looks a little
> more direct to use mas->end to locate the offset.
> 
> Also ma_data_end() returns slot index instead of count.

nack

> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>  lib/maple_tree.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 17533c246749..dda8e292c25b 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -2168,7 +2168,7 @@ static inline void mas_node_or_none(struct ma_state *mas,
>  static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas)
>  {
>  	struct ma_state *mas = wr_mas->mas;
> -	unsigned char count, offset;
> +	unsigned char offset;
>  
>  	if (unlikely(ma_is_dense(wr_mas->type))) {
>  		wr_mas->r_max = wr_mas->r_min = mas->index;
> @@ -2178,11 +2178,11 @@ static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas)
>  
>  	wr_mas->node = mas_mn(wr_mas->mas);
>  	wr_mas->pivots = ma_pivots(wr_mas->node, wr_mas->type);
> -	count = mas->end = ma_data_end(wr_mas->node, wr_mas->type,
> +	mas->end = ma_data_end(wr_mas->node, wr_mas->type,
>  				       wr_mas->pivots, mas->max);
>  	offset = mas->offset;
>  
> -	while (offset < count && mas->index > wr_mas->pivots[offset])
> +	while (offset < mas->end && mas->index > wr_mas->pivots[offset])
>  		offset++;
>  
>  	wr_mas->r_max = mas_safe_pivot(mas, wr_mas->pivots, offset, wr_mas->type);
> -- 
> 2.34.1
> 
>
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 17533c246749..dda8e292c25b 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2168,7 +2168,7 @@  static inline void mas_node_or_none(struct ma_state *mas,
 static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas)
 {
 	struct ma_state *mas = wr_mas->mas;
-	unsigned char count, offset;
+	unsigned char offset;
 
 	if (unlikely(ma_is_dense(wr_mas->type))) {
 		wr_mas->r_max = wr_mas->r_min = mas->index;
@@ -2178,11 +2178,11 @@  static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas)
 
 	wr_mas->node = mas_mn(wr_mas->mas);
 	wr_mas->pivots = ma_pivots(wr_mas->node, wr_mas->type);
-	count = mas->end = ma_data_end(wr_mas->node, wr_mas->type,
+	mas->end = ma_data_end(wr_mas->node, wr_mas->type,
 				       wr_mas->pivots, mas->max);
 	offset = mas->offset;
 
-	while (offset < count && mas->index > wr_mas->pivots[offset])
+	while (offset < mas->end && mas->index > wr_mas->pivots[offset])
 		offset++;
 
 	wr_mas->r_max = mas_safe_pivot(mas, wr_mas->pivots, offset, wr_mas->type);