]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Cleanup unpack_object_header to use only offsets.
authorShawn Pearce <spearce@spearce.org>
Sat, 26 Aug 2006 08:12:04 +0000 (04:12 -0400)
committerJunio C Hamano <junkio@cox.net>
Sun, 27 Aug 2006 00:35:20 +0000 (17:35 -0700)
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>
sha1_file.c

index 461768c317289531e81c44d496daea7fcfdb2f5c..7f4145c1870e30fc36dfe81b8b659dacedc1bb59 100644 (file)
@@ -917,23 +917,19 @@ static unsigned long unpack_object_header(struct packed_git *p, unsigned long of
        enum object_type *type, unsigned long *sizep)
 {
        unsigned shift;
-       unsigned char *pack, c;
+       unsigned char c;
        unsigned long size;
 
        if (offset >= p->pack_size)
                die("object offset outside of pack file");
-
-       pack =  (unsigned char *) p->pack_base + offset;
-       c = *pack++;
-       offset++;
+       c = *((unsigned char *)p->pack_base + offset++);
        *type = (c >> 4) & 7;
        size = c & 15;
        shift = 4;
        while (c & 0x80) {
                if (offset >= p->pack_size)
                        die("object offset outside of pack file");
-               c = *pack++;
-               offset++;
+               c = *((unsigned char *)p->pack_base + offset++);
                size += (c & 0x7f) << shift;
                shift += 7;
        }