static inline void append_node_cp(struct maple_copy *cp,
struct ma_state *mas, unsigned char start, unsigned char end)
{
- unsigned char count = cp->s_count;
+ struct maple_node *node;
+ enum maple_type mt;
+ unsigned char count;
+
+ count = cp->s_count;
+ node = mas_mn(mas);
+ mt = mte_node_type(mas->node);
+
+ cp->src[count].node = node;
+ cp->src[count].mt = mt;
+ if (mas->end <= end)
+ cp->src[count].max = mas->max;
+ else
+ cp->src[count].max = ma_pivots(node, mt)[end];
- cp->src[count].node = mas_mn(mas);
- cp->src[count].mt = mte_node_type(mas->node);
- cp->src[count].max = mas->max;
cp->src[count].start = start;
cp->src[count].end = end;
cp->s_count++;
* Leaf nodes are a bit tricky because we cannot assume the data
* can fit due to the NULL limitation on node ends.
*/
- off = cp->split;;
+ off = cp->split;
for (s = 0; s < cp->s_count; s++) {
unsigned char s_off;
unsigned char data, data_offset;
unsigned char src_end, s_offset;
unsigned char split, next_node, size;
- unsigned long s_max;
+ unsigned long s_max, d_max;
enum maple_type s_mt, d_mt;
s = d = 0;
if (split - dst_offset + 1 < size)
size = split - dst_offset + 1;
- node_copy(mas, src, s_offset, size, s_max, s_mt, dst,
- dst_offset, d_mt);
+ d_max = node_copy(mas, src, s_offset, size, s_max, s_mt,
+ dst, dst_offset, d_mt);
data_offset += size;
dst_offset += size;
s_offset += size;
if (s_offset > src_end) {
/* This source is exhausted */
- cp->dst[d].max = s_max;
s++;
if (s >= cp->s_count) {
+ cp->dst[d].max = d_max;
node_finalise(dst, d_mt, dst_offset);
return;
}
+ d_max = s_max;
/* Reset local src */
src = cp->src[s].node;
s_offset = cp->src[s].start;
next_node = data + 1;
split = cp->split;
- if (dst_offset <= mt_pivots[d_mt]) {
- cp->dst[d].max = ma_pivots(dst, d_mt)[dst_offset - 1];
- } else {
- cp->dst[d].max = ma_pivots(src, s_mt)[s_offset - 1];
- }
-
+ cp->dst[d].max = d_max;
/* Handle null entries */
if (cp->dst[d].max != ULONG_MAX &&
!ma_slots(dst, d_mt)[dst_offset - 1]) {