unsigned long piv, *pivots = ma_pivots(mas_mn(mas), type);
if (pivots[offset]) {
- while (offset < mt_slots[type]) {
+ do {
piv = mas_logical_pivot(mas, pivots, offset, type);
if (piv >= mas->max)
break;
- offset++;
- }
+ } while (++offset < mt_slots[type]);
} else {
- offset--;
- do {
- if (pivots[offset])
+ while (--offset) {
+ if (pivots[offset]) {
+ if (pivots[offset] < mas->max)
+ offset++;
break;
- } while (--offset);
- if (pivots[offset] < mas->max)
- offset++;
+ }
+ };
}
return offset;
static inline unsigned long mas_leaf_max_gap(struct ma_state *mas)
{
enum maple_type mt = mte_node_type(mas->node);
- unsigned long *pivots = ma_pivots(mas_mn(mas), mt);
unsigned long pstart, pend, gap = 0, max_gap = 0;
- void **slots = ma_slots(mas_mn(mas), mt);
+ struct maple_node *mn = mas_mn(mas);
+ unsigned long *pivots = ma_pivots(mn, mt);
+ void **slots = ma_slots(mn, mt);
unsigned char i;
if (ma_is_dense(mt)) {
for (i = 0; i < mt_slot_count(mas->node); i++) {
- if (mas_slot_locked(mas, slots, i)) {
+ if (slots[i]) {
if (gap > max_gap)
max_gap = gap;
gap = 0;
if (piv > mas->last) // Contained in this pivot
return false;
+ if (ma_is_leaf(type)) {
+ if (mas->last < mas->max) // Fits in the node, but may span slots.
+ return false;
+
+ if ((mas->last == mas->max) && entry) // Writes to the end of the node but not null.
+ return false;
+ } else if ((piv == mas->last) && entry) {
+ return false;
+ }
+
/* Writing ULONG_MAX is not a spanning write regardless of the value
* being written as long as the range fits in the node.
*/
if ((mas->last == ULONG_MAX) && (mas->last == mas->max))
return false;
- if (ma_is_leaf(type)) {
- if (mas->last < mas->max) // Fits in the node, but may span slots.
- return false;
- if (entry && (mas->last == mas->max)) // Writes to the end of the node but not null.
- return false;
- } else {
- if (entry && piv == mas->last)
- return false;
- }
trace_mas_is_span_wr(mas, piv, entry);
return true;
return false;
if (ma_is_leaf(type))
- break;
+ return true;
// Traverse.
mas->max = *range_max;
retry:
if (_mas_walk(mas, range_min, range_max)) {
- unsigned char slot = MAPLE_NODE_SLOTS;
+ unsigned char offset = MAPLE_NODE_SLOTS;
if (mas_is_ptr(mas) && mas->last == 0)
return mte_safe_root(mas->tree->ma_root);
- slot = mas_offset(mas);
- if (slot >= MAPLE_NODE_SLOTS)
+ offset = mas_offset(mas);
+ if (offset >= MAPLE_NODE_SLOTS)
return NULL;
- entry = mas_get_slot(mas, slot);
+ entry = mas_get_slot(mas, offset);
if (mte_dead_node(mas->node))
goto retry;
}