[PATCH 2/3] maple_tree: use mas_safe_pivot() to get the pivot range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Before modifying data, we need to walk the tree to locate the
maple_node. Also we get the range boundary at offset/offset_end.

For the upper boundary at offset, we have defined function
mas_safe_pivot() to get it. Let's leverage it.

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

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 85668246f944..17533c246749 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -2185,7 +2185,7 @@ static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas)
 	while (offset < count && mas->index > wr_mas->pivots[offset])
 		offset++;
 
-	wr_mas->r_max = offset < count ? wr_mas->pivots[offset] : mas->max;
+	wr_mas->r_max = mas_safe_pivot(mas, wr_mas->pivots, offset, wr_mas->type);
 	wr_mas->r_min = mas_safe_min(mas, wr_mas->pivots, offset);
 	wr_mas->offset_end = mas->offset = offset;
 }
@@ -3987,11 +3987,9 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas)
 		    (mas->end != wr_mas->offset_end) &&
 		    !wr_mas->slots[wr_mas->offset_end + 1]) {
 			wr_mas->offset_end++;
-			if (wr_mas->offset_end == mas->end)
-				mas->last = mas->max;
-			else
-				mas->last = wr_mas->pivots[wr_mas->offset_end];
-			wr_mas->end_piv = mas->last;
+			wr_mas->end_piv = mas->last =
+				mas_safe_pivot(mas, wr_mas->pivots,
+					wr_mas->offset_end, wr_mas->type);
 		}
 	}
 
@@ -4016,10 +4014,8 @@ static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas)
 	       (wr_mas->mas->last > wr_mas->pivots[wr_mas->offset_end]))
 		wr_mas->offset_end++;
 
-	if (wr_mas->offset_end < wr_mas->mas->end)
-		wr_mas->end_piv = wr_mas->pivots[wr_mas->offset_end];
-	else
-		wr_mas->end_piv = wr_mas->mas->max;
+	wr_mas->end_piv = mas_safe_pivot(wr_mas->mas, wr_mas->pivots,
+				wr_mas->offset_end, wr_mas->type);
 
 	if (!wr_mas->entry)
 		mas_wr_extend_null(wr_mas);
-- 
2.34.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux