summaryrefslogtreecommitdiff
path: root/diff-delta.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2005-06-29 04:27:45 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-29 04:38:47 (GMT)
commit69a2d426f0d249bca2c6f754b3c1283c0fa72fd4 (patch)
treeb71e760d5a5da66dda5170b9c2ad6073c10f9814 /diff-delta.c
parent9d5ab9625ddb53a68a99516225d0bcb39ec473d5 (diff)
downloadgit-69a2d426f0d249bca2c6f754b3c1283c0fa72fd4.zip
git-69a2d426f0d249bca2c6f754b3c1283c0fa72fd4.tar.gz
git-69a2d426f0d249bca2c6f754b3c1283c0fa72fd4.tar.bz2
[PATCH] denser delta header encoding
Since the delta data format is not tied to any actual git object anymore, now is the time to add a small improvement to the delta data header as it is been done for packed object header. This patch allows for reducing the delta header of about 2 bytes and makes for simpler code. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff-delta.c')
-rw-r--r--diff-delta.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/diff-delta.c b/diff-delta.c
index fd9b37f..67f6081 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -228,28 +228,22 @@ void *diff_delta(void *from_buf, unsigned long from_size,
top = to_buf + to_size;
/* store reference buffer size */
- orig = out + outpos++;
- *orig = i = 0;
- do {
- if (from_size & 0xff) {
- *orig |= (1 << i);
- out[outpos++] = from_size;
- }
- i++;
- from_size >>= 8;
- } while (from_size);
+ out[outpos++] = from_size;
+ from_size >>= 7;
+ while (from_size) {
+ out[outpos - 1] |= 0x80;
+ out[outpos++] = from_size;
+ from_size >>= 7;
+ }
/* store target buffer size */
- orig = out + outpos++;
- *orig = i = 0;
- do {
- if (to_size & 0xff) {
- *orig |= (1 << i);
- out[outpos++] = to_size;
- }
- i++;
- to_size >>= 8;
- } while (to_size);
+ out[outpos++] = to_size;
+ to_size >>= 7;
+ while (to_size) {
+ out[outpos - 1] |= 0x80;
+ out[outpos++] = to_size;
+ to_size >>= 7;
+ }
inscnt = 0;
moff = 0;