Skip to content

Commit

Permalink
3% tighter packs for free
Browse files Browse the repository at this point in the history
This patch makes for 3.4% smaller pack with the git repository, and
a bit more than 3% smaller pack with the kernel repository.

And so with _no_ measurable CPU difference.

Signed-off-by: Nicolas Pitre <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Mar 18, 2006
1 parent 71bb103 commit 5a1fb2c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion diff-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ void *diff_delta(void *from_buf, unsigned long from_size,
unsigned long *delta_size,
unsigned long max_size)
{
unsigned int i, outpos, outsize, inscnt, hash_shift;
unsigned int i, outpos, outsize, hash_shift;
int inscnt;
const unsigned char *ref_data, *ref_top, *data, *top;
unsigned char *out;
struct index *entry, **hash;
Expand Down Expand Up @@ -222,6 +223,20 @@ void *diff_delta(void *from_buf, unsigned long from_size,
unsigned char *op;

if (inscnt) {
while (moff && ref_data[moff-1] == data[-1]) {
if (msize == 0x10000)
break;
/* we can match one byte back */
msize++;
moff--;
data--;
outpos--;
if (--inscnt)
continue;
outpos--; /* remove count slot */
inscnt--; /* make it -1 */
break;
}
out[outpos - inscnt - 1] = inscnt;
inscnt = 0;
}
Expand Down

0 comments on commit 5a1fb2c

Please sign in to comment.