Commit 71a54317 by Patrick Steinhardt

khash: avoid using `kh_key` directly

parent cb18386f
......@@ -199,10 +199,8 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
if (!git_oidmap_valid_index(cache->map, pos)) {
int rval;
pos = kh_put(oid, cache->map, &entry->oid, &rval);
git_oidmap_insert(cache->map, &entry->oid, entry, rval);
if (rval >= 0) {
kh_key(cache->map, pos) = &entry->oid;
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);
......@@ -221,7 +219,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
git_cached_obj_decref(stored_entry);
git_cached_obj_incref(entry);
kh_key(cache->map, pos) = &entry->oid;
git_oidmap_key(cache->map, pos) = &entry->oid;
git_oidmap_value_at(cache->map, pos) = entry;
} else {
/* NO OP */
......
......@@ -57,7 +57,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
obj->len = len;
obj->type = type;
kh_key(db->objects, pos) = &obj->oid;
git_oidmap_key(db->objects, pos) = &obj->oid;
git_oidmap_value_at(db->objects, pos) = obj;
if (type == GIT_OBJ_COMMIT) {
......
......@@ -39,6 +39,7 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
#define git_oidmap_exists(h, k) (kh_get(oid, h, k) != kh_end(h))
#define git_oidmap_has_data(h, idx) kh_exist(h, idx)
#define git_oidmap_key(h, idx) kh_key(h, idx)
#define git_oidmap_value_at(h, idx) kh_val(h, idx)
#define git_oidmap_insert(h, key, val, rval) do { \
......
......@@ -299,7 +299,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
goto done;
if (!error)
kh_key(sc->map, pos) = item_key;
git_strmap_key(sc->map, pos) = item_key;
git_strmap_value_at(sc->map, pos) = item;
error = git_vector_insert(&sc->items, item);
......
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