maple_tree: Inline ma_max_gap() in mas_update_gap()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 30 Nov 2024 04:30:52 +0000 (23:30 -0500)
committerLiam R. Howlett <howlett@gmail.com>
Mon, 27 Jan 2025 20:43:03 +0000 (15:43 -0500)
ma_max_gap is called from a single location and can benefit from the
setup in mas_update_gap, so inline it.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 49997a0fe1aa61932e8cdd58264bec5d4f49a50b..9b010072265c0846547ec3d91188caeb25fe0823 100644 (file)
@@ -1589,36 +1589,6 @@ static unsigned long mas_leaf_max_gap(struct ma_state *mas)
        return max_gap;
 }
 
-/*
- * ma_max_gap() - Get the maximum gap in a maple node (non-leaf)
- * @node: The maple node
- * @gaps: The pointer to the gaps
- * @mt: The maple node type
- * @off: Pointer to store the offset location of the gap.
- *
- * Uses the metadata data end to scan backwards across set gaps.
- *
- * Return: The maximum gap value
- */
-static inline unsigned long
-ma_max_gap(struct maple_node *node, unsigned long *gaps, enum maple_type mt,
-           unsigned char *off)
-{
-       unsigned char offset, i;
-       unsigned long max_gap = 0;
-
-       i = offset = ma_meta_end(node, mt);
-       do {
-               if (gaps[i] > max_gap) {
-                       max_gap = gaps[i];
-                       offset = i;
-               }
-       } while (i--);
-
-       *off = offset;
-       return max_gap;
-}
-
 /*
  * mas_max_gap() - find the largest gap in a non-leaf node and set the slot.
  * @mas: The maple state.
@@ -1683,7 +1653,17 @@ ascend:
 
                ma_set_meta_gap(pnode, pmt, offset);
        } else if (new < meta_gap) {
-               new = ma_max_gap(pnode, pgaps, pmt, &meta_offset);
+               unsigned char i;
+
+               /* Get the new maximum gap in the node */
+               i = meta_offset = ma_meta_end(pnode, pmt);
+               new = pgaps[i];
+               while (i--) {
+                       if (pgaps[i] > new) {
+                               new = pgaps[i];
+                               meta_offset = i;
+                       }
+               }
                ma_set_meta_gap(pnode, pmt, meta_offset);
        }