diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2010-02-16 05:31:28 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2010-02-16 05:31:28 +0000 |
commit | ef262b0786a71e26112ec3dd7a5f5aad03c7313d (patch) | |
tree | d0febc7dd4c8c3ad0aa70770d580b7f26777d9fe /xdelta3/xdelta3.c | |
parent | 2410f9aa90750bc4c9892ae631a48cb4089a4e46 (diff) |
Fix an off-by-one error in srcwin_move_point, and prevent updating
xd3_source_eof () when eof is known in xd3_getblk. Now performance
is the same for FIFO and no.
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r-- | xdelta3/xdelta3.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 4f91318..ea9bb19 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -2540,8 +2540,11 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno) | |||
2540 | 2540 | ||
2541 | if (blkno >= source->frontier_blkno) | 2541 | if (blkno >= source->frontier_blkno) |
2542 | { | 2542 | { |
2543 | source->max_blkno = blkno; | 2543 | if (blkno > source->max_blkno) |
2544 | source->onlastblk = source->onblk; | 2544 | { |
2545 | source->max_blkno = blkno; | ||
2546 | source->onlastblk = source->onblk; | ||
2547 | } | ||
2545 | 2548 | ||
2546 | if (source->onblk == source->blksize) | 2549 | if (source->onblk == source->blksize) |
2547 | { | 2550 | { |
@@ -2616,7 +2619,9 @@ xd3_set_source (xd3_stream *stream, | |||
2616 | } | 2619 | } |
2617 | 2620 | ||
2618 | int | 2621 | int |
2619 | xd3_set_source_and_size (xd3_stream *stream, xd3_source *user_source, xoff_t source_size) { | 2622 | xd3_set_source_and_size (xd3_stream *stream, |
2623 | xd3_source *user_source, | ||
2624 | xoff_t source_size) { | ||
2620 | int ret = xd3_set_source (stream, user_source); | 2625 | int ret = xd3_set_source (stream, user_source); |
2621 | if (ret == 0) | 2626 | if (ret == 0) |
2622 | { | 2627 | { |
@@ -2790,7 +2795,8 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst) | |||
2790 | else | 2795 | else |
2791 | { | 2796 | { |
2792 | stream->srcwin_decided_early = (!stream->src->eof_known || | 2797 | stream->srcwin_decided_early = (!stream->src->eof_known || |
2793 | (stream->srcwin_cksum_pos < xd3_source_eof (stream->src))); | 2798 | (stream->srcwin_cksum_pos < |
2799 | xd3_source_eof (stream->src))); | ||
2794 | } | 2800 | } |
2795 | 2801 | ||
2796 | /* xtra field indicates the copy is from the source */ | 2802 | /* xtra field indicates the copy is from the source */ |
@@ -5109,7 +5115,8 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5109 | } | 5115 | } |
5110 | 5116 | ||
5111 | IF_DEBUG1 (DP(RINT | 5117 | IF_DEBUG1 (DP(RINT |
5112 | "[srcwin_move_point] exited loop T=%"Q"u{%"Q"u} S=%"Q"u EOF=%"Q"u %s\n", | 5118 | "[srcwin_move_point] exited loop T=%"Q"u{%"Q"u} " |
5119 | "S=%"Q"u EOF=%"Q"u %s\n", | ||
5113 | stream->total_in + stream->input_position, | 5120 | stream->total_in + stream->input_position, |
5114 | logical_input_cksum_pos, | 5121 | logical_input_cksum_pos, |
5115 | stream->srcwin_cksum_pos, | 5122 | stream->srcwin_cksum_pos, |
@@ -5120,7 +5127,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5120 | { | 5127 | { |
5121 | source_size = xd3_source_eof (stream->src); | 5128 | source_size = xd3_source_eof (stream->src); |
5122 | 5129 | ||
5123 | if (stream->srcwin_cksum_pos >= source_size) | 5130 | if (stream->srcwin_cksum_pos > source_size) |
5124 | { | 5131 | { |
5125 | /* This invariant is needed for xd3_source_cksum_offset() */ | 5132 | /* This invariant is needed for xd3_source_cksum_offset() */ |
5126 | stream->srcwin_cksum_pos = source_size; | 5133 | stream->srcwin_cksum_pos = source_size; |