git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Pearce <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH 4/5] Cleanup unpack_object_header to use only offsets.
Date: Sat, 26 Aug 2006 04:12:04 -0400	[thread overview]
Message-ID: <20060826081204.GF22343@spearce.org> (raw)

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>
---
 sha1_file.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index b580cee..e6d47c1 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -917,23 +917,19 @@ static unsigned long unpack_object_heade
 	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;
 	}
-- 
1.4.2.g6580

                 reply	other threads:[~2006-08-26  8:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060826081204.GF22343@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).