unsigned char i;
unsigned char max_piv;
- if (ma_is_dense(mt)) {
+ if (unlikely(ma_is_dense(mt))) {
for (i = 0; i < mt_slots[mt]; i++) {
if (slots[i]) {
if (gap > max_gap)
return gaps[offset];
}
-static inline unsigned long mas_tree_gap(struct ma_state *mas)
-{
- struct maple_node *pnode;
- unsigned long *gaps;
- enum maple_type mt;
- if (!mte_is_root(mas->node)) {
-
- pnode = mte_parent(mas->node);
- mt = mas_parent_enum(mas, mas->node);
- gaps = ma_gaps(pnode, mt);
- return gaps[mte_parent_slot(mas->node)];
-
- }
- return mas_max_gap(mas);
-}
static inline void mas_parent_gap(struct ma_state *mas, unsigned char offset,
unsigned long new)
{
if (piv > mas->last) // Contained in this pivot
return false;
- if (ma_is_leaf(type)) {
+ if (unlikely(ma_is_leaf(type))) {
if (mas->last < mas->max) // Fits in the node, but may span slots.
return false;
static inline bool mas_node_store(struct ma_state *mas, void *entry,
unsigned long min, unsigned long max,
- unsigned char end, void *content)
+ unsigned char end, void *content,
+ enum maple_type mt, void **slots,
+ unsigned long *pivots)
{
- enum maple_type mt = mte_node_type(mas->node);
- struct maple_node *node = mas_mn(mas);
- void **dst_slots, **slots = ma_slots(node, mt);
- unsigned long *dst_pivots, *pivots = ma_pivots(node, mt);
+ void **dst_slots;
+ unsigned long *dst_pivots;
unsigned char dst_offset, new_end = end;
unsigned char offset, offset_end;
struct maple_node reuse, *newnode;
static inline bool mas_slot_store(struct ma_state *mas, void *entry,
unsigned long min, unsigned long max,
- unsigned char end, void *content)
+ unsigned char end, void *content,
+ enum maple_type mt, void **slots)
{
- enum maple_type mt = mte_node_type(mas->node);
struct maple_node *node = mas_mn(mas);
- void **slots = ma_slots(node, mt);
unsigned long *pivots = ma_pivots(node, mt);
unsigned long lmax; // Logical max.
unsigned char offset = mas->offset;
return true;
try_node_store:
- return mas_node_store(mas, entry, min, max, end, content);
+ return mas_node_store(mas, entry, min, max, end, content, mt, slots, pivots);
}
static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite)
unsigned char end;
void *content = NULL;
struct maple_big_node b_node;
+ void **slots;
+ enum maple_type mt;
int ret = 0;
/* At this point, we are at the leaf node that needs to be altered. */
/* Calculate needed space */
- content = mas_get_slot(mas, mas->offset);
+ mt = mte_node_type(mas->node);
+ slots = ma_slots(mas_mn(mas), mt);
+ content = slots[mas->offset];
if (!overwrite && ((mas->last > r_max) || content)) {
mas_set_err(mas, -EEXIST);
return content;
}
if (!entry) {
- enum maple_type mt = mte_node_type(mas->node);
- unsigned long *pivots = ma_pivots(mas_mn(mas), mt);
- void **slots = ma_slots(mas_mn(mas), mt);
unsigned char offset_end = mas->offset;
if (!content) {
mas->last = r_max;
// if this one is null the next and prev are not.
} else {
+ unsigned long *pivots = ma_pivots(mas_mn(mas), 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 &&
}
end = mas_data_end(mas);
- if (mas_slot_store(mas, entry, r_min, r_max, end, content))
+ if (mas_slot_store(mas, entry, r_min, r_max, end, content, mt, slots))
return content;
if (mas_is_err(mas))