Skip to content

Commit 4f8ec74

Browse files
committed
index-pack: a miniscule refactor
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 <[email protected]>
1 parent 3c9fc07 commit 4f8ec74

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

builtin/index-pack.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,17 @@ static void sha1_object(const void *data, unsigned long size,
498498
}
499499
}
500500

501+
static int is_delta_type(enum object_type type)
502+
{
503+
return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
504+
}
505+
501506
static void *get_base_data(struct base_data *c)
502507
{
503508
if (!c->data) {
504509
struct object_entry *obj = c->obj;
505510

506-
if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
511+
if (is_delta_type(obj->type)) {
507512
void *base = get_base_data(c->base);
508513
void *raw = get_data_from_pack(obj);
509514
c->data = patch_delta(
@@ -629,7 +634,7 @@ static void parse_pack_objects(unsigned char *sha1)
629634
struct object_entry *obj = &objects[i];
630635
void *data = unpack_raw_entry(obj, &delta->base);
631636
obj->real_type = obj->type;
632-
if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
637+
if (is_delta_type(obj->type)) {
633638
nr_deltas++;
634639
delta->obj_no = i;
635640
delta++;
@@ -676,7 +681,7 @@ static void parse_pack_objects(unsigned char *sha1)
676681
struct object_entry *obj = &objects[i];
677682
struct base_data base_obj;
678683

679-
if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA)
684+
if (is_delta_type(obj->type))
680685
continue;
681686
base_obj.obj = obj;
682687
base_obj.data = NULL;

0 commit comments

Comments
 (0)