git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 1/4] index-pack: a miniscule refactor
Date: Fri,  3 Jun 2011 15:32:14 -0700	[thread overview]
Message-ID: <1307140337-27676-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1307140337-27676-1-git-send-email-gitster@pobox.com>

Introduce a helper function that takes the type of an object and
tell if it is a delta, as we seem to use this check in many places.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/index-pack.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 513fbbc..0216af7 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -498,12 +498,17 @@ static void sha1_object(const void *data, unsigned long size,
 	}
 }
 
+static int is_delta_type(enum object_type type)
+{
+	return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
+}
+
 static void *get_base_data(struct base_data *c)
 {
 	if (!c->data) {
 		struct object_entry *obj = c->obj;
 
-		if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
+		if (is_delta_type(obj->type)) {
 			void *base = get_base_data(c->base);
 			void *raw = get_data_from_pack(obj);
 			c->data = patch_delta(
@@ -629,7 +634,7 @@ static void parse_pack_objects(unsigned char *sha1)
 		struct object_entry *obj = &objects[i];
 		void *data = unpack_raw_entry(obj, &delta->base);
 		obj->real_type = obj->type;
-		if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
+		if (is_delta_type(obj->type)) {
 			nr_deltas++;
 			delta->obj_no = i;
 			delta++;
@@ -676,7 +681,7 @@ static void parse_pack_objects(unsigned char *sha1)
 		struct object_entry *obj = &objects[i];
 		struct base_data base_obj;
 
-		if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA)
+		if (is_delta_type(obj->type))
 			continue;
 		base_obj.obj = obj;
 		base_obj.data = NULL;
-- 
1.7.6.rc0.106.g68174

  reply	other threads:[~2011-06-03 22:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 22:32 [PATCH 0/4] index-pack (continued) Junio C Hamano
2011-06-03 22:32 ` Junio C Hamano [this message]
2011-06-03 22:32 ` [PATCH 2/4] index-pack: start learning to emulate "verify-pack -v" Junio C Hamano
2011-06-03 22:32 ` [PATCH 3/4] index-pack: show histogram when emulating " Junio C Hamano
2011-06-03 22:32 ` [PATCH 4/4] verify-pack: use index-pack --verify Junio C Hamano

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=1307140337-27676-2-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /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).