}
}
-/*
- * mas_dup_state() - duplicate the internal state of a ma_state.
- * @dst - the destination to store the state information
- * @src - the source of the state information
- */
-static inline void mas_dup_state(struct ma_state *dst, struct ma_state *src)
-{
- dst->tree = src->tree;
- dst->index = src->index;
- dst->last = src->last;
- dst->node = src->node;
- dst->max = src->max;
- dst->min = src->min;
- dst->offset = src->offset;
- dst->mas_flags = src->mas_flags;
-}
-
/*
* mas_descend() - Descend into the slot stored in the ma_state.
* @mas - the maple state.
break;
if (mte_parent(entry) == node) {
- mas_dup_state(child, mas);
+ *child = *mas;
mas->offset = offset + 1;
child->offset = offset;
mas_descend(child);
int i, n;
for (i = 0; i < 3; i++) {
- mas_dup_state(&list[i], mas);
+ list[i] = *mas;
list[i].offset = 0;
next[i].offset = 0;
}
- mas_dup_state(&next[0], mas);
+ next[0] = *mas;
while (!mte_is_leaf(list[0].node)) {
/* descend by setting the list to the children */
for (i = 0; i < 3; i++)
- mas_dup_state(&list[i], &next[i]);
+ list[i] = next[i];
}
}
if (mte_is_root(mas->node))
return false;
- mas_dup_state(&parent, mas);
+ parent = *mas;
mas_ascend(&parent);
end = mas_data_end(&parent);
parent.offset = mte_parent_slot(mas->node) + 1;
if (!mas_get_slot(&parent, parent.offset))
return false;
- mas_dup_state(mas, &parent);
+ *mas = parent;
mas_descend(mas);
return true;
}
MA_STATE(tmp, mast->orig_r->tree, mast->orig_r->index, mast->orig_r->last);
- mas_dup_state(&tmp, mast->orig_r);
+ tmp = *mast->orig_r;
mas_next_node(mast->orig_r, ULONG_MAX);
if (!mas_is_none(mast->orig_r)) {
mast_rebalance_next(mast, old_r, free);
return true;
}
- mas_dup_state(mast->orig_r, mast->orig_l);
- mas_dup_state(mast->r, mast->l);
+ *mast->orig_r = *mast->orig_l;
+ *mast->r = *mast->l;
mas_prev_node(mast->orig_l, 0);
if (mas_is_none(mast->orig_l)) {
/* Making a new root with the contents of mast->bn */
- mas_dup_state(mast->orig_l, mast->orig_r);
- mas_dup_state(mast->orig_r, &tmp);
+ *mast->orig_l = *mast->orig_r;
+ *mast->orig_r = tmp;
return false;
}
if (!mte_dead_node(mast->orig_l->node))
mat_add(&free, mast->orig_l->node);
- mas_dup_state(mast->orig_l, &l_mas);
mas->depth = mast->orig_l->depth;
+ *mast->orig_l = l_mas;
mte_set_node_dead(mas->node);
/* Set up mas for insertion. */
- mas_dup_state(mas, mast->orig_l);
+ mast->orig_l->depth = mas->depth;
+ mast->orig_l->alloc = mas->alloc;
+ *mas = *mast->orig_l;
mas_wmb_replace(mas, &free, &destroy);
mas->offset = restore.offset;
mas->min = restore.min;
mast.orig_r = &r_mas;
mast.bn = b_node;
- mas_dup_state(&l_mas, mas);
- mas_dup_state(&r_mas, mas);
+ l_mas = r_mas = *mas;
if (mas_next_sibling(&r_mas)) {
mas_mab_cp(&r_mas, 0, mt_slot_count(r_mas.node), b_node, b_end);
MA_STATE(l_mas, mas->tree, mas->index, mas->last);
- mas_dup_state(&l_mas, mas);
+ l_mas = *mas;
mas_prev_sibling(&l_mas);
/* set up node. */
unsigned char end, space, split;
MA_STATE(tmp_mas, mas->tree, mas->index, mas->last);
+ tmp_mas = *mas;
tmp_mas.depth = mast->l->depth;
- tmp_mas.node = mas->node;
if (left && !mas_prev_sibling(&tmp_mas))
return false;
if (left) {
/* Switch mas to prev node */
mat_add(mast->free, mas->node);
- mas_dup_state(mas, &tmp_mas);
+ *mas = tmp_mas;
/* Start using mast->l for the left side. */
tmp_mas.node = mast->l->node;
- mas_dup_state(mast->l, &tmp_mas);
+ *mast->l = tmp_mas;
} else {
mat_add(mast->free, tmp_mas.node);
tmp_mas.node = mast->r->node;
- mas_dup_state(mast->r, &tmp_mas);
+ *mast->r = tmp_mas;
split = slot_total - split;
}
split = mab_no_null_split(mast->bn, split, mt_slots[mast->bn->type]);
if (mas_split_final_node(&mast, mas, height))
break;
- mas_dup_state(&l_mas, mas);
- mas_dup_state(&r_mas, mas);
+ l_mas = r_mas = *mas;
l_mas.node = mas_new_ma_node(mas, b_node);
r_mas.node = mas_new_ma_node(mas, b_node);
/* Try to push left. */
*/
mast.r->max = mas->max;
mast_fill_bnode(&mast, mas, 1);
- mas_dup_state(&prev_l_mas, mast.l);
- mas_dup_state(&prev_r_mas, mast.r);
+ prev_l_mas = *mast.l;
+ prev_r_mas = *mast.r;
}
/* Set the original node as dead */
mast.orig_r = &r_mas;
/* Set up right side. */
- mas_dup_state(&r_mas, mas);
+ r_mas = *mas;
r_mas.depth = mas->depth;
/* Avoid overflow. */
if (r_mas.last + 1)
r_mas.last = r_mas.index = mas->last;
/* Set up left side. */
- mas_dup_state(&l_mas, mas);
+ l_mas = *mas;
l_mas.depth = mas->depth;
l_mas.offset = 0;
__mas_walk(&l_mas, &range_min, &range_max);