}
static inline void
-mas_ascend_free(struct ma_state *l_mas, struct ma_state *r_mas,
- struct ma_topiary *free)
-{
- struct maple_enode *left = l_mas->node;
- struct maple_enode *right = r_mas->node;
- mas_ascend(l_mas);
- mas_ascend(r_mas);
- mat_add(free, left);
+mast_ascend_free(struct maple_subtree_state *mast)
+{
+ struct maple_enode *left = mast->orig_l->node;
+ struct maple_enode *right = mast->orig_r->node;
+ mas_ascend(mast->orig_l);
+ mas_ascend(mast->orig_r);
+ mat_add(mast->free, left);
if (left != right)
- mat_add(free, right);
+ mat_add(mast->free, right);
+ mas_set_slot(mast->orig_l, 0);
+ mas_set_slot(mast->orig_r, 0);
}
static inline struct maple_enode
if (mt_is_alloc(mas->tree))
mas_update_gap(mas, false);
}
+static inline void mast_new_root(struct maple_subtree_state *mast,
+ struct ma_state *mas)
+{
+ unsigned long range_min, range_max;
+ mas_mn(mast->l)->parent =
+ ma_parent_ptr(((unsigned long)mas->tree | MA_ROOT_PARENT));
+ mas->depth = mast->orig_l->depth;
+ mast->bn->b_end = 0;
+ if (mte_is_root(mast->orig_l->node)) {
+ if ((mast->orig_l->node != mas->node) &&
+ (mast->l->depth > mas->tree->ma_height)) {
+ mat_add(mast->free, mas->node);
+ }
+ } else {
+ do {
+ mast_ascend_free(mast);
+ mas_node_walk(mast->orig_l,
+ mte_node_type(mast->orig_l->node),
+ &range_min, &range_max);
+ mas_node_walk(mast->orig_r,
+ mte_node_type(mast->orig_r->node),
+ &range_min, &range_max);
+ mast_consume(mast);
+ } while (!mte_is_root(mast->orig_l->node));
+ }
+ mat_add(mast->free, mast->orig_l->node);
+ mas_dup_state(mast->orig_l, mast->l);
+}
/* Private
*
* mas_combine_separate() - Follow the tree upwards from @l_mas and @r_mas for
* Returns the number of elements in b_node during the last loop.
*/
static inline int mas_combine_separate(struct ma_state *mas,
- struct maple_subtree_state *mast, unsigned char count)
+ struct maple_subtree_state *mast, unsigned char count)
{
unsigned char split, r_end, mid_split;
unsigned char slot = 0, l_slot = 0;
mast->orig_l->depth++;
if (!l_mas.min && l_mas.max == ULONG_MAX) {
- mas_mn(&l_mas)->parent = ma_parent_ptr(
- ((unsigned long)mas->tree | MA_ROOT_PARENT));
- mas->depth = mast->orig_l->depth;
- mast->bn->b_end = 0;
- if (mte_is_root(mast->orig_l->node)) {
- if ((mast->orig_l->node != mas->node) &&
- (l_mas.depth > mas->tree->ma_height)) {
- mat_add(&free, mas->node);
- }
- } else {
- do {
- mas_ascend_free(mast->orig_l, mast->orig_r,
- &free);
- mas_set_slot(mast->orig_l, 0);
- mas_set_slot(mast->orig_r, 0);
- mas_node_walk(mast->orig_l,
- mte_node_type(mast->orig_l->node),
- &range_min, &range_max);
- mas_node_walk(mast->orig_r,
- mte_node_type(mast->orig_r->node),
- &range_min, &range_max);
- mast_consume(mast);
- } while (!mte_is_root(mast->orig_l->node));
- }
- mat_add(mast->free, mast->orig_l->node);
- mas_dup_state(mast->orig_l, &l_mas);
+ mast_new_root(mast, mas);
goto new_root;
}
- mas_ascend_free(mast->orig_l, mast->orig_r, &free);
+ mast_ascend_free(mast);
/* Set up the right side of things */
r_end = mas_data_end(mast->orig_r);
- mas_set_slot(mast->orig_r, 0);
mast->orig_r->index = r_mas.max;
/* last should be larger than or equal to index */
if (mast->orig_r->last < mast->orig_r->index)
mas_set_slot(mast->orig_r, r_end + 1);
}
/* Set up the left side of things */
- mas_set_slot(mast->orig_l, 0);
mast->orig_l->index = l_mas.min;
mas_node_walk(mast->orig_l, mte_node_type(mast->orig_l->node),
&range_min, &range_max);
}
static inline int mas_split(struct ma_state *mas,
- struct maple_big_node *b_node)
+ struct maple_big_node *b_node)
{
struct maple_enode *ancestor = MAS_NONE;