@matheusbsbs / matheus-bagliano / commits / 5a1fb2ca92
Fork 0

3% tighter packs for free

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 <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nicolas Pitre committed Mar 17, 2006 at 22:45 UTC 5a1fb2ca92caaa7ae9044ab81dc102f59d17b97a
1 file changed +16 -1
diff-delta.c
+16 -1
@@ -136,7 +136,8 @@ void *diff_delta(void *from_buf, unsigned long from_size,
136 unsigned long *delta_size,
137 unsigned long max_size)
138 {
139 - unsigned int i, outpos, outsize, inscnt, hash_shift;
139 + unsigned int i, outpos, outsize, hash_shift;
140 + int inscnt;
141 const unsigned char *ref_data, *ref_top, *data, *top;
142 unsigned char *out;
143 struct index *entry, **hash;
@@ -222,6 +223,20 @@ void *diff_delta(void *from_buf, unsigned long from_size,
223 unsigned char *op;
224
225 if (inscnt) {
226 + while (moff && ref_data[moff-1] == data[-1]) {
227 + if (msize == 0x10000)
228 + break;
229 + /* we can match one byte back */
230 + msize++;
231 + moff--;
232 + data--;
233 + outpos--;
234 + if (--inscnt)
235 + continue;
236 + outpos--; /* remove count slot */
237 + inscnt--; /* make it -1 */
238 + break;
239 + }
240 out[outpos - inscnt - 1] = inscnt;
241 inscnt = 0;
242 }