mas_node_count(mas, 1);
- if (mas_is_err(mas))
+ if (unlikely(mas_is_err(mas)))
return 0;
node = mas_pop_node(mas);
pivots = ma_pivots(node, type);
slots = ma_slots(node, type);
- mas->node = mt_mk_node(node, type);
- mas_mn(mas)->parent = ma_parent_ptr(
+ node->parent = ma_parent_ptr(
((unsigned long)mas->tree | MA_ROOT_PARENT));
+ mas->node = mt_mk_node(node, type);
if (contents)
slots[slot++] = contents;
slots[slot] = entry;
pivots[slot++] = mas->last;
- /* swap the new root into the tree */
- rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
mas->depth = 1;
mas_set_height(mas);
+ /* swap the new root into the tree */
+ rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
return slot;
}
-static inline int ma_root_ptr(struct ma_state *mas, void *entry,
- void *contents, bool overwrite)
+static inline int ma_root_ptr(struct ma_state *mas, void *entry, bool overwrite)
{
int ret = 1;
return 0;
if (mas_root(mas) && mas->last == 0) {
- contents = mas_root_locked(mas);
if (!overwrite)
goto exists;
- } else {
- contents = NULL;
- }
+ } else
if (mas->last != 0)
ret = mas_root_expand(mas, entry);
if (mas_start(mas) || mas_is_none(mas) || mas->node == MAS_ROOT) {
- ret = ma_root_ptr(mas, entry, content, overwrite);
+ ret = ma_root_ptr(mas, entry, overwrite);
if (mas_is_err(mas))
return NULL;
if (ret)