old_parent = mt_parent(mas->node);
p_slot = mt_parent_slot(mas->node);
p_end = ma_data_end_r64(&old_parent->mr64, UINT_MAX);
+ ma_encoded_parent(mas);
if (p_end >= MAPLE_RANGE64_SLOTS - 1) {
/* Must split the parent */
- ma_encoded_parent(mas);
split = ma_split(mas, p_slot, p_end, 1);
if (mas_is_err(mas))
return 0;
p_slot -= split;
// Split will return the parent.
old_parent = mt_to_node(mas->node);
- } else {
- ma_encoded_parent(mas);
}
ptype = mt_node_type(mas->node);
mas->node = old_parent->mr64.slot[p_slot];
ma_link(left, new_parent, p_slot, pivot, ctype);
- // Set up maple state for replacement of node.
- // Note: old_parent may be the old parent or the full node.
+ // Set up maple state to replace the parent node in the grandparent.
mas->node = mt_mk_node(new_parent, ptype);
// Replace the parent node & free the old parent.
mt_replace(mas);
// Set up the ma_state for the return. Point to the correct node for
- // the insert.
+ // the insert or subsequent split.
if (mas->index <= pivot)
mas->node = mt_mk_node(left, ctype);
else