mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-18 19:14:55 +00:00
khash: avoid using kh_get
directly
This commit is contained in:
parent
64e46dc3b5
commit
a853c52723
@ -156,7 +156,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
|
||||
if (!git_cache__enabled || git_rwlock_rdlock(&cache->lock) < 0)
|
||||
return NULL;
|
||||
|
||||
pos = kh_get(oid, cache->map, oid);
|
||||
pos = git_oidmap_lookup_index(cache->map, oid);
|
||||
if (git_oidmap_valid_index(cache->map, pos)) {
|
||||
entry = kh_val(cache->map, pos);
|
||||
|
||||
@ -193,7 +193,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
|
||||
if (git_cache__current_storage.val > git_cache__max_storage)
|
||||
cache_evict_entries(cache);
|
||||
|
||||
pos = kh_get(oid, cache->map, &entry->oid);
|
||||
pos = git_oidmap_lookup_index(cache->map, &entry->oid);
|
||||
|
||||
/* not found */
|
||||
if (!git_oidmap_valid_index(cache->map, pos)) {
|
||||
|
@ -82,7 +82,7 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
|
||||
struct memobject *obj = NULL;
|
||||
khiter_t pos;
|
||||
|
||||
pos = kh_get(oid, db->objects, oid);
|
||||
pos = git_oidmap_lookup_index(db->objects, oid);
|
||||
if (!git_oidmap_valid_index(db->objects, pos))
|
||||
return GIT_ENOTFOUND;
|
||||
|
||||
@ -103,7 +103,7 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
|
||||
struct memobject *obj = NULL;
|
||||
khiter_t pos;
|
||||
|
||||
pos = kh_get(oid, db->objects, oid);
|
||||
pos = git_oidmap_lookup_index(db->objects, oid);
|
||||
if (!git_oidmap_valid_index(db->objects, pos))
|
||||
return GIT_ENOTFOUND;
|
||||
|
||||
|
@ -516,7 +516,7 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
|
||||
|
||||
GIT_UNUSED(name);
|
||||
|
||||
pos = kh_get(oid, pb->object_ix, oid);
|
||||
pos = git_oidmap_lookup_index(pb->object_ix, oid);
|
||||
if (!git_oidmap_valid_index(pb->object_ix, pos))
|
||||
return 0;
|
||||
|
||||
|
@ -117,7 +117,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
|
||||
if (git_mutex_lock(&cache->lock) < 0)
|
||||
return NULL;
|
||||
|
||||
k = kh_get(off, cache->entries, offset);
|
||||
k = git_offmap_lookup_index(cache->entries, offset);
|
||||
if (git_offmap_valid_index(cache->entries, k)) { /* found it */
|
||||
entry = kh_value(cache->entries, k);
|
||||
git_atomic_inc(&entry->refcount);
|
||||
@ -956,7 +956,7 @@ git_off_t get_delta_base(
|
||||
git_oid oid;
|
||||
|
||||
git_oid_fromraw(&oid, base_info);
|
||||
k = kh_get(oid, p->idx_cache, &oid);
|
||||
k = git_oidmap_lookup_index(p->idx_cache, &oid);
|
||||
if (git_oidmap_valid_index(p->idx_cache, k)) {
|
||||
*curpos += 20;
|
||||
return ((struct git_pack_entry *)kh_value(p->idx_cache, k))->offset;
|
||||
|
@ -25,7 +25,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
|
||||
int ret;
|
||||
|
||||
/* lookup and reserve space if not already present */
|
||||
pos = kh_get(oid, walk->commits, oid);
|
||||
pos = git_oidmap_lookup_index(walk->commits, oid);
|
||||
if (git_oidmap_valid_index(walk->commits, pos))
|
||||
return kh_value(walk->commits, pos);
|
||||
|
||||
|
@ -33,7 +33,7 @@ void test_core_oidmap__basic(void)
|
||||
khiter_t pos;
|
||||
int ret;
|
||||
|
||||
pos = kh_get(oid, map, &items[i].oid);
|
||||
pos = git_oidmap_lookup_index(map, &items[i].oid);
|
||||
cl_assert(!git_oidmap_valid_index(map, pos));
|
||||
|
||||
pos = kh_put(oid, map, &items[i].oid, &ret);
|
||||
@ -46,7 +46,7 @@ void test_core_oidmap__basic(void)
|
||||
for (i = 0; i < NITEMS; ++i) {
|
||||
khiter_t pos;
|
||||
|
||||
pos = kh_get(oid, map, &items[i].oid);
|
||||
pos = git_oidmap_lookup_index(map, &items[i].oid);
|
||||
cl_assert(git_oidmap_valid_index(map, pos));
|
||||
|
||||
cl_assert_equal_p(kh_val(map, pos), &items[i]);
|
||||
@ -87,7 +87,7 @@ void test_core_oidmap__hash_collision(void)
|
||||
khiter_t pos;
|
||||
int ret;
|
||||
|
||||
pos = kh_get(oid, map, &items[i].oid);
|
||||
pos = git_oidmap_lookup_index(map, &items[i].oid);
|
||||
cl_assert(!git_oidmap_valid_index(map, pos));
|
||||
|
||||
pos = kh_put(oid, map, &items[i].oid, &ret);
|
||||
@ -100,7 +100,7 @@ void test_core_oidmap__hash_collision(void)
|
||||
for (i = 0; i < NITEMS; ++i) {
|
||||
khiter_t pos;
|
||||
|
||||
pos = kh_get(oid, map, &items[i].oid);
|
||||
pos = git_oidmap_lookup_index(map, &items[i].oid);
|
||||
cl_assert(git_oidmap_valid_index(map, pos));
|
||||
|
||||
cl_assert_equal_p(kh_val(map, pos), &items[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user