From: Liam R. Howlett Date: Sat, 30 Nov 2024 04:30:52 +0000 (-0500) Subject: maple_tree: Inline ma_max_gap() in mas_update_gap() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3a20a605324c6490d20e42e82fdca52c220e645c;p=users%2Fjedix%2Flinux-maple.git maple_tree: Inline ma_max_gap() in mas_update_gap() 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 --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 49997a0fe1aa..9b010072265c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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); }