{
void *entry = NULL;
- if (unlikely(mas_is_err(mas)))
- return NULL;
-
if (likely(mas_is_start(mas))) {
struct maple_enode *root;
if (mas_root(mas) && mas->last == 0) {
if (!overwrite)
goto exists;
- } else
+ }
if (mas->last != 0)
ret = mas_root_expand(mas, entry);
int ret = 0;
- if (mas_is_err(mas))
- return NULL;
-
-
if (mas_start(mas) || mas_is_none(mas) || mas->node == MAS_ROOT) {
ret = ma_root_ptr(mas, entry, overwrite);
if (mas_is_err(mas))
return NULL;
+
if (ret)
goto complete_at_root;
}
node = mas_mn(mas);
slots = ma_slots(node, mt);
content = slots[mas->offset];
- if (!overwrite && (content || (mas->last > r_max))) {
+ if (unlikely(!overwrite) && (content || (mas->last > r_max))) {
mas_set_err(mas, -EEXIST);
return content;
}
unsigned char offset_end = mas->offset;
if (!content) {
- if (mas->index > r_min)
- mas->index = r_min;
+ mas->index = r_min;
if (mas->last < r_max)
mas->last = r_max;
// if this one is null the next and prev are not.
} else {
unsigned long *pivots = ma_pivots(node, mt);
+
// Check next slot if we are overwriting the end.
if ((mas->last == r_max) && !slots[mas->offset + 1]) {
if (mas->offset < mt_pivots[mt] - 1 &&