Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-03-03 17:50:47 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-03-04 02:18:29 +0400
commit0e040c031edc6b61692e74a9b8ce0b0ff86d270a (patch)
tree4133f94021429088a726c210cacf9df010c74e6f /src/pack.c
parent29ab8774e53d1c053802b69f4e66283a23e7290a (diff)
indexer: use a hashtable for keeping track of offsets
These offsets are needed for REF_DELTA objects, which encode which object they use as a base, but not where it lies in the packfile, so we need a list. These objects are mostly from older packfiles, before OFS_DELTA was widely spread. The time spent in indexing these packfiles is greatly reduced, though remains above what git is able to do.
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pack.c b/src/pack.c
index f36f3cf6b..75ac98186 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -760,13 +760,14 @@ git_off_t get_delta_base(
} else if (type == GIT_OBJ_REF_DELTA) {
/* If we have the cooperative cache, search in it first */
if (p->has_cache) {
- size_t pos;
- struct git_pack_entry key;
+ khiter_t k;
+ git_oid oid;
- git_oid_fromraw(&key.sha1, base_info);
- if (!git_vector_bsearch(&pos, &p->cache, &key)) {
+ git_oid_fromraw(&oid, base_info);
+ k = kh_get(oid, p->idx_cache, &oid);
+ if (k != kh_end(p->idx_cache)) {
*curpos += 20;
- return ((struct git_pack_entry *)git_vector_get(&p->cache, pos))->offset;
+ return ((struct git_pack_entry *)kh_value(p->idx_cache, k))->offset;
}
}
/* The base entry _must_ be in the same pack */