X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/edecdad54de4c47609319d469ec41fbd36c0ab35..b9f592fbf50b0dc9e3d1d33b8deb2bf9abad9ef6:/match.c diff --git a/match.c b/match.c index 6909fca3..d731aae7 100644 --- a/match.c +++ b/match.c @@ -22,6 +22,7 @@ extern int verbose; extern int am_server; extern int do_progress; +extern int checksum_seed; typedef unsigned short tag; @@ -141,14 +142,14 @@ static void hash_search(int f,struct sum_struct *s, { OFF_T offset, end; unsigned int k; - size_t last_i; + size_t want_i; char sum2[SUM_LENGTH]; uint32 s1, s2, sum; schar *map; - /* last_i is used to encourage adjacent matches, allowing the RLL coding of the - output to work more efficiently */ - last_i = (size_t)-1; + /* want_i is used to encourage adjacent matches, allowing the RLL + * coding of the output to work more efficiently. */ + want_i = 0; if (verbose > 2) { rprintf(FINFO,"hash search b=%u len=%.0f\n", @@ -187,7 +188,7 @@ static void hash_search(int f,struct sum_struct *s, sum = (s1 & 0xffff) | (s2 << 16); tag_hits++; - for (; j < s->count && targets[j].t == t; j++) { + do { unsigned int l; size_t i = targets[j].i; @@ -215,22 +216,15 @@ static void hash_search(int f,struct sum_struct *s, } /* we've found a match, but now check to see - * if last_i can hint at a better match */ - for (j++; j < s->count && targets[j].t == t; j++) { - size_t i2 = targets[j].i; - if (i2 == last_i + 1) { - if (sum != s->sums[i2].sum1) - break; - if (memcmp(sum2,s->sums[i2].sum2,s->s2length) != 0) - break; - /* we've found an adjacent match - the RLL coder - * will be happy */ - i = i2; - break; - } + * if want_i can hint at a better match. */ + if (i != want_i && want_i < s->count + && sum == s->sums[want_i].sum1 + && memcmp(sum2, s->sums[want_i].sum2, s->s2length) == 0) { + /* we've found an adjacent match - the RLL coder + * will be happy */ + i = want_i; } - - last_i = i; + want_i = i + 1; matched(f,s,buf,offset,i); offset += s->sums[i].len - 1; @@ -241,7 +235,7 @@ static void hash_search(int f,struct sum_struct *s, s2 = sum >> 16; matches++; break; - } + } while (++j < s->count && targets[j].t == t); null_tag: /* Trim off the first byte from the checksum */ @@ -291,7 +285,6 @@ static void hash_search(int f,struct sum_struct *s, void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len) { char file_sum[MD4_SUM_LENGTH]; - extern int write_batch; last_match = 0; false_alarms = 0; @@ -299,7 +292,7 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len) matches = 0; data_transfer = 0; - sum_init(); + sum_init(checksum_seed); if (len > 0 && s->count>0) { build_hash_table(s); @@ -329,8 +322,6 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len) if (verbose > 2) rprintf(FINFO,"sending file_sum\n"); write_buf(f,file_sum,MD4_SUM_LENGTH); - if (write_batch) - write_batch_delta_file(file_sum, MD4_SUM_LENGTH); if (targets) { free(targets);