@matheusbsbs / matheus-bagliano / commits / 465b26eeef
Fork 0

Cleanup unpack_object_header to use only offsets.

If we're always incrementing both the offset and the pointer we aren't gaining anything by keeping both. Instead just use the offset since that's what we were given and what we are expected to return. Also using offset is likely to make it easier to remap the pack in the future should partial mapping of very large packs get implemented. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed Aug 26, 2006 at 04:12 UTC 465b26eeef79e3cb4cb6276e405e59d986069926
1 file changed +3 -7
sha1_file.c
+3 -7
@@ -917,23 +917,19 @@ static unsigned long unpack_object_header(struct packed_git *p, unsigned long of
917 enum object_type *type, unsigned long *sizep)
918 {
919 unsigned shift;
920 - unsigned char *pack, c;
920 + unsigned char c;
921 unsigned long size;
922
923 if (offset >= p->pack_size)
924 die("object offset outside of pack file");
925 -
926 - pack = (unsigned char *) p->pack_base + offset;
927 - c = *pack++;
928 - offset++;
925 + c = *((unsigned char *)p->pack_base + offset++);
926 *type = (c >> 4) & 7;
927 size = c & 15;
928 shift = 4;
929 while (c & 0x80) {
930 if (offset >= p->pack_size)
931 die("object offset outside of pack file");
935 - c = *pack++;
936 - offset++;
932 + c = *((unsigned char *)p->pack_base + offset++);
933 size += (c & 0x7f) << shift;
934 shift += 7;
935 }