Commit cb18386f by Patrick Steinhardt

khash: avoid using `kh_val`/`kh_value` directly

parent 76e671a6
......@@ -128,7 +128,7 @@ static void cache_evict_entries(git_cache *cache)
khiter_t pos = seed++ % git_oidmap_end(cache->map);
if (git_oidmap_has_data(cache->map, pos)) {
git_cached_obj *evict = kh_val(cache->map, pos);
git_cached_obj *evict = git_oidmap_value_at(cache->map, pos);
evict_count--;
evicted_memory += evict->size;
......@@ -158,7 +158,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
pos = git_oidmap_lookup_index(cache->map, oid);
if (git_oidmap_valid_index(cache->map, pos)) {
entry = kh_val(cache->map, pos);
entry = git_oidmap_value_at(cache->map, pos);
if (flags && entry->flags != flags) {
entry = NULL;
......@@ -202,7 +202,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
pos = kh_put(oid, cache->map, &entry->oid, &rval);
if (rval >= 0) {
kh_key(cache->map, pos) = &entry->oid;
kh_val(cache->map, pos) = entry;
git_oidmap_value_at(cache->map, pos) = entry;
git_cached_obj_incref(entry);
cache->used_memory += entry->size;
git_atomic_ssize_add(&git_cache__current_storage, (ssize_t)entry->size);
......@@ -210,7 +210,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
}
/* found */
else {
git_cached_obj *stored_entry = kh_val(cache->map, pos);
git_cached_obj *stored_entry = git_oidmap_value_at(cache->map, pos);
if (stored_entry->flags == entry->flags) {
git_cached_obj_decref(entry);
......@@ -222,7 +222,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
git_cached_obj_incref(entry);
kh_key(cache->map, pos) = &entry->oid;
kh_val(cache->map, pos) = entry;
git_oidmap_value_at(cache->map, pos) = entry;
} else {
/* NO OP */
}
......
......@@ -308,7 +308,7 @@ static int store_object(git_indexer *idx)
}
kh_value(idx->pack->idx_cache, k) = pentry;
git_oidmap_value_at(idx->pack->idx_cache, k) = pentry;
git_oid_cpy(&entry->oid, &oid);
......@@ -356,7 +356,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
return -1;
}
kh_value(idx->pack->idx_cache, k) = pentry;
git_oidmap_value_at(idx->pack->idx_cache, k) = pentry;
/* Add the object to the list */
if (git_vector_insert(&idx->objects, entry) < 0)
......
......@@ -58,7 +58,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
obj->type = type;
kh_key(db->objects, pos) = &obj->oid;
kh_val(db->objects, pos) = obj;
git_oidmap_value_at(db->objects, pos) = obj;
if (type == GIT_OBJ_COMMIT) {
struct memobject **store = git_array_alloc(db->commits);
......@@ -86,7 +86,7 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
if (!git_oidmap_valid_index(db->objects, pos))
return GIT_ENOTFOUND;
obj = kh_val(db->objects, pos);
obj = git_oidmap_value_at(db->objects, pos);
*len_p = obj->len;
*type_p = obj->type;
......@@ -107,7 +107,7 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
if (!git_oidmap_valid_index(db->objects, pos))
return GIT_ENOTFOUND;
obj = kh_val(db->objects, pos);
obj = git_oidmap_value_at(db->objects, pos);
*len_p = obj->len;
*type_p = obj->type;
......
......@@ -200,7 +200,7 @@ static void rehash(git_packbuilder *pb)
git_oidmap_clear(pb->object_ix);
for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) {
pos = kh_put(oid, pb->object_ix, &po->id, &ret);
kh_value(pb->object_ix, pos) = po;
git_oidmap_value_at(pb->object_ix, pos) = po;
}
}
......@@ -252,7 +252,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
return ret;
}
assert(ret != 0);
kh_value(pb->object_ix, pos) = po;
git_oidmap_value_at(pb->object_ix, pos) = po;
pb->done = false;
......@@ -520,7 +520,7 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
if (!git_oidmap_valid_index(pb->object_ix, pos))
return 0;
po = kh_value(pb->object_ix, pos);
po = git_oidmap_value_at(pb->object_ix, pos);
po->tagged = 1;
/* TODO: peel objects */
......
......@@ -119,7 +119,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t 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);
entry = git_offmap_value_at(cache->entries, k);
git_atomic_inc(&entry->refcount);
entry->last_usage = cache->use_ctr++;
}
......@@ -171,7 +171,7 @@ static int cache_add(
k = kh_put(off, cache->entries, offset, &error);
assert(error != 0);
kh_value(cache->entries, k) = entry;
git_oidmap_value_at(cache->entries, k) = entry;
cache->memory_used += entry->raw.len;
*cached_out = entry;
......@@ -959,7 +959,7 @@ git_off_t get_delta_base(
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;
return ((struct git_pack_entry *)git_oidmap_value_at(p->idx_cache, k))->offset;
} else {
/* If we're building an index, don't try to find the pack
* entry; we just haven't seen it yet. We'll make
......
......@@ -27,7 +27,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
/* lookup and reserve space if not already present */
pos = git_oidmap_lookup_index(walk->commits, oid);
if (git_oidmap_valid_index(walk->commits, pos))
return kh_value(walk->commits, pos);
return git_oidmap_value_at(walk->commits, pos);
commit = git_commit_list_alloc_node(walk);
if (commit == NULL)
......@@ -37,7 +37,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
pos = kh_put(oid, walk->commits, &commit->oid, &ret);
assert(ret != 0);
kh_value(walk->commits, pos) = commit;
git_oidmap_value_at(walk->commits, pos) = commit;
return commit;
}
......
......@@ -300,7 +300,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
if (!error)
kh_key(sc->map, pos) = item_key;
kh_val(sc->map, pos) = item;
git_strmap_value_at(sc->map, pos) = item;
error = git_vector_insert(&sc->items, item);
if (error < 0)
......
......@@ -39,7 +39,7 @@ void test_core_oidmap__basic(void)
pos = kh_put(oid, map, &items[i].oid, &ret);
cl_assert(ret != 0);
kh_val(map, pos) = &items[i];
git_oidmap_value_at(map, pos) = &items[i];
}
......@@ -49,7 +49,7 @@ void test_core_oidmap__basic(void)
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]);
cl_assert_equal_p(git_oidmap_value_at(map, pos), &items[i]);
}
git_oidmap_free(map);
......@@ -93,7 +93,7 @@ void test_core_oidmap__hash_collision(void)
pos = kh_put(oid, map, &items[i].oid, &ret);
cl_assert(ret != 0);
kh_val(map, pos) = &items[i];
git_oidmap_value_at(map, pos) = &items[i];
}
......@@ -103,7 +103,7 @@ void test_core_oidmap__hash_collision(void)
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]);
cl_assert_equal_p(git_oidmap_value_at(map, pos), &items[i]);
}
git_oidmap_free(map);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment