summaryrefslogtreecommitdiff
path: root/src/pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pack.c b/src/pack.c
index f0ebf9d37..4b43e7cf1 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -473,6 +473,18 @@ off_t get_delta_base(
return 0; /* out of bound */
*curpos += used;
} else if (type == GIT_OBJ_REF_DELTA) {
+ /* If we have the cooperative cache, search in it first */
+ if (p->has_cache) {
+ int pos;
+ struct git_pack_entry key;
+
+ git_oid_fromraw(&key.sha1, base_info);
+ pos = git_vector_bsearch(&p->cache, &key);
+ if (pos >= 0) {
+ *curpos += 20;
+ return ((struct git_pack_entry *)git_vector_get(&p->cache, pos))->offset;
+ }
+ }
/* The base entry _must_ be in the same pack */
if (pack_entry_find_offset(&base_offset, &unused, p, (git_oid *)base_info, GIT_OID_HEXSZ) < GIT_SUCCESS)
return git__rethrow(GIT_EPACKCORRUPTED, "Base entry delta is not in the same pack");