Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2005-06-29 08:27:45 +0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-29 08:38:47 +0400
commit69a2d426f0d249bca2c6f754b3c1283c0fa72fd4 (patch)
treeb71e760d5a5da66dda5170b9c2ad6073c10f9814 /patch-delta.c
parent9d5ab9625ddb53a68a99516225d0bcb39ec473d5 (diff)
[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 'patch-delta.c')
-rw-r--r--patch-delta.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/patch-delta.c b/patch-delta.c
index a8d75ee1c8..b68dd13c63 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -22,33 +22,33 @@ void *patch_delta(void *src_buf, unsigned long src_size,
unsigned long size;
int i;
- /* the smallest delta size possible is 6 bytes */
- if (delta_size < 6)
+ /* the smallest delta size possible is 4 bytes */
+ if (delta_size < 4)
return NULL;
data = delta_buf;
top = delta_buf + delta_size;
/* make sure the orig file size matches what we expect */
- size = i = 0;
cmd = *data++;
- while (cmd) {
- if (cmd & 1)
- size |= *data++ << i;
- i += 8;
- cmd >>= 1;
+ size = cmd & ~0x80;
+ i = 7;
+ while (cmd & 0x80) {
+ cmd = *data++;
+ size |= (cmd & ~0x80) << i;
+ i += 7;
}
if (size != src_size)
return NULL;
/* now the result size */
- size = i = 0;
cmd = *data++;
- while (cmd) {
- if (cmd & 1)
- size |= *data++ << i;
- i += 8;
- cmd >>= 1;
+ size = cmd & ~0x80;
+ i = 7;
+ while (cmd & 0x80) {
+ cmd = *data++;
+ size |= (cmd & ~0x80) << i;
+ i += 7;
}
dst_buf = malloc(size);
if (!dst_buf)