Skip to content

Commit

Permalink
pack-objects: no crc check when the cached version is used
Browse files Browse the repository at this point in the history
Current code makes pack-objects always do check_pack_crc() in
unpack_entry() even if right after that we find out there's a cached
version and pack access is not needed. Swap two code blocks, search
for cached version first, then check crc.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Sep 13, 2013
1 parent e230c56 commit 77965f8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,16 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
int i;
struct delta_base_cache_entry *ent;

ent = get_delta_base_cache_entry(p, curpos);
if (eq_delta_base_cache_entry(ent, p, curpos)) {
type = ent->type;
data = ent->data;
size = ent->size;
clear_delta_base_cache_entry(ent);
base_from_cache = 1;
break;
}

if (do_check_packed_object_crc && p->index_version > 1) {
struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
unsigned long len = revidx[1].offset - obj_offset;
Expand All @@ -2070,16 +2080,6 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
}
}

ent = get_delta_base_cache_entry(p, curpos);
if (eq_delta_base_cache_entry(ent, p, curpos)) {
type = ent->type;
data = ent->data;
size = ent->size;
clear_delta_base_cache_entry(ent);
base_from_cache = 1;
break;
}

type = unpack_object_header(p, &w_curs, &curpos, &size);
if (type != OBJ_OFS_DELTA && type != OBJ_REF_DELTA)
break;
Expand Down

0 comments on commit 77965f8

Please sign in to comment.