diff options
Diffstat (limited to 'xdelta3-merge.h')
-rw-r--r-- | xdelta3-merge.h | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/xdelta3-merge.h b/xdelta3-merge.h index 6e46a3d..e65978d 100644 --- a/xdelta3-merge.h +++ b/xdelta3-merge.h @@ -258,8 +258,8 @@ xd3_whole_append_window (xd3_stream *stream) /* xd3_merge_input_output applies *source to *stream, returns the * result in stream. */ -static int xd3_merge_input_output (xd3_stream *stream, - xd3_whole_state *source) +int xd3_merge_input_output (xd3_stream *stream, + xd3_whole_state *source) { int ret; xd3_stream tmp_stream; @@ -446,7 +446,7 @@ xd3_merge_source_copy (xd3_stream *stream, XD3_ASSERT (sinst->size > sinst_offset); sinst_left = sinst->size - sinst_offset; - this_take = xd3_min (iinst.size, sinst_left); + this_take = min (iinst.size, sinst_left); XD3_ASSERT (this_take > 0); @@ -492,15 +492,10 @@ xd3_merge_source_copy (xd3_stream *stream, } else { - // Note: A better implementation will construct the - // mapping of output ranges, starting from the input - // range, applying deltas in forward order, using an - // interval tree. This code uses recursion to construct - // each copied range, recursively (using binary search - // in xd3_merge_find_position). - // - // TODO: This code can cause stack overflow. Fix as - // described above. + // TODO: this is slow because of the recursion, which + // could reach a depth equal to the number of target + // copies, and this is compression-inefficient because + // it can produce duplicate adds. xd3_winst tinst; tinst.type = XD3_CPY; tinst.mode = iinst.mode; @@ -560,14 +555,12 @@ int xd3_merge_inputs (xd3_stream *stream, ret = xd3_merge_add (stream, input, iinst); break; default: - if (iinst->mode == 0) + /* TODO: VCD_TARGET support is completely untested all + * throughout. */ + if (iinst->mode == 0 || iinst->mode == VCD_TARGET) { ret = xd3_merge_target_copy (stream, iinst); } - else if (iinst->mode == VCD_TARGET) - { - ret = XD3_INVALID_INPUT; - } else { ret = xd3_merge_source_copy (stream, source, iinst); |