unsigned long range = mas->max - mas->min;
unsigned long half;
unsigned long piv = 0;
+ unsigned long min_range = 8;
enum maple_type mas_type = mte_node_type(mas->node);
- if (mas_type == maple_arange_64)
+ if (mas_type == maple_arange_64) {
max = 5;
+ ret = 5;
+ }
+
+ if (!ma_is_leaf(mas_type)) {
+ min_range *= max;
+ if (mas->max == ULONG_MAX) {
+ max--;
+ ret--;
+ }
+ }
if (!active) {
if (ma_is_leaf(mas_type))
return max - 2;
}
- //if (mas->min == 0)
- // max = 7;
-
half = max / 2;
- if (ma_is_leaf(mas_type)) {
- if (range <= 8UL)
- return ret;
-
- for (slot = 0; slot <= mt_pivots[mas_type]; slot++) {
- piv = mas_get_safe_pivot(mas, slot);
+ if (range <= min_range)
+ return ret;
- if (!piv && slot)
- return ret;
+ for (slot = 0; slot <= mt_pivots[mas_type]; slot++) {
+ piv = mas_get_safe_pivot(mas, slot);
- range = piv - mas->min;
- if (range >= 8) {
- if (slot > half)
- ret = slot;
- else
- ret = half;
- goto done;
- }
+ if (!piv && slot)
+ return ret;
+ range = piv - mas->min;
+ if (range >= min_range) {
+ if (slot > half)
+ ret = (max > slot ? slot : max);
+ else
+ ret = half;
+ goto done;
}
- }
- return half;
+ }
done:
if (ret < max && (piv == ULONG_MAX))