summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-09-13 18:03:00 +0700
committerJunio C Hamano <gitster@pobox.com>2013-09-13 11:28:33 -0700
commit77965f8b29f8311c42a0a770693dd0f8411e84db (patch)
tree3db16333b84e7f2b3f4231acf65f3b51f68e7511 /sha1_file.c
parente230c568c4b9a991e3175e5f65171a566fd8e39c (diff)
downloadgit-77965f8b29f8311c42a0a770693dd0f8411e84db.tar.gz
pack-objects: no crc check when the cached version is usednd/unpack-entry-optim-in-pack-objects
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 8e27db1bd2..6f5a1e0717 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -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;
@@ -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;