Commit 85d2748c by Patrick Steinhardt

khash: avoid using `kh_key`/`kh_val` as lvalue

parent f31cb45a
...@@ -219,8 +219,8 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry) ...@@ -219,8 +219,8 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
git_cached_obj_decref(stored_entry); git_cached_obj_decref(stored_entry);
git_cached_obj_incref(entry); git_cached_obj_incref(entry);
git_oidmap_key(cache->map, pos) = &entry->oid; git_oidmap_set_key_at(cache->map, pos, &entry->oid);
git_oidmap_value_at(cache->map, pos) = entry; git_oidmap_set_value_at(cache->map, pos, entry);
} else { } else {
/* NO OP */ /* NO OP */
} }
......
...@@ -308,7 +308,7 @@ static int store_object(git_indexer *idx) ...@@ -308,7 +308,7 @@ static int store_object(git_indexer *idx)
} }
git_oidmap_value_at(idx->pack->idx_cache, k) = pentry; git_oidmap_set_value_at(idx->pack->idx_cache, k, pentry);
git_oid_cpy(&entry->oid, &oid); git_oid_cpy(&entry->oid, &oid);
...@@ -356,7 +356,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent ...@@ -356,7 +356,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
return -1; return -1;
} }
git_oidmap_value_at(idx->pack->idx_cache, k) = pentry; git_oidmap_set_value_at(idx->pack->idx_cache, k, pentry);
/* Add the object to the list */ /* Add the object to the list */
if (git_vector_insert(&idx->objects, entry) < 0) if (git_vector_insert(&idx->objects, entry) < 0)
......
...@@ -57,8 +57,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void ...@@ -57,8 +57,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
obj->len = len; obj->len = len;
obj->type = type; obj->type = type;
git_oidmap_key(db->objects, pos) = &obj->oid; git_oidmap_set_key_at(db->objects, pos, &obj->oid);
git_oidmap_value_at(db->objects, pos) = obj; git_oidmap_set_value_at(db->objects, pos, obj);
if (type == GIT_OBJ_COMMIT) { if (type == GIT_OBJ_COMMIT) {
struct memobject **store = git_array_alloc(db->commits); struct memobject **store = git_array_alloc(db->commits);
......
...@@ -39,9 +39,11 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid) ...@@ -39,9 +39,11 @@ 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_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_has_data(h, idx) kh_exist(h, idx)
#define git_oidmap_key(h, idx) kh_key(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_set_key_at(h, idx, k) kh_key(h, idx) = k
#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx) #define git_oidmap_value_at(h, idx) kh_val(h, idx)
#define git_oidmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx)
#define git_oidmap_put(h, k, err) kh_put(oid, h, k, err) #define git_oidmap_put(h, k, err) kh_put(oid, h, k, err)
......
...@@ -200,7 +200,7 @@ static void rehash(git_packbuilder *pb) ...@@ -200,7 +200,7 @@ static void rehash(git_packbuilder *pb)
git_oidmap_clear(pb->object_ix); git_oidmap_clear(pb->object_ix);
for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) { for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) {
pos = git_oidmap_put(pb->object_ix, &po->id, &ret); pos = git_oidmap_put(pb->object_ix, &po->id, &ret);
git_oidmap_value_at(pb->object_ix, pos) = po; git_oidmap_set_value_at(pb->object_ix, pos, po);
} }
} }
...@@ -252,7 +252,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, ...@@ -252,7 +252,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
return ret; return ret;
} }
assert(ret != 0); assert(ret != 0);
git_oidmap_value_at(pb->object_ix, pos) = po; git_oidmap_set_value_at(pb->object_ix, pos, po);
pb->done = false; pb->done = false;
......
...@@ -171,7 +171,7 @@ static int cache_add( ...@@ -171,7 +171,7 @@ static int cache_add(
k = git_offmap_put(cache->entries, offset, &error); k = git_offmap_put(cache->entries, offset, &error);
assert(error != 0); assert(error != 0);
git_oidmap_value_at(cache->entries, k) = entry; git_offmap_set_value_at(cache->entries, k, entry);
cache->memory_used += entry->raw.len; cache->memory_used += entry->raw.len;
*cached_out = entry; *cached_out = entry;
......
...@@ -37,7 +37,7 @@ git_commit_list_node *git_revwalk__commit_lookup( ...@@ -37,7 +37,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
pos = git_oidmap_put(walk->commits, &commit->oid, &ret); pos = git_oidmap_put(walk->commits, &commit->oid, &ret);
assert(ret != 0); assert(ret != 0);
git_oidmap_value_at(walk->commits, pos) = commit; git_oidmap_set_value_at(walk->commits, pos, commit);
return commit; return commit;
} }
......
...@@ -299,8 +299,8 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key) ...@@ -299,8 +299,8 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
goto done; goto done;
if (!error) if (!error)
git_strmap_key(sc->map, pos) = item_key; git_strmap_set_key_at(sc->map, pos, item_key);
git_strmap_value_at(sc->map, pos) = item; git_strmap_set_value_at(sc->map, pos, item);
error = git_vector_insert(&sc->items, item); error = git_vector_insert(&sc->items, item);
if (error < 0) if (error < 0)
......
...@@ -38,6 +38,7 @@ typedef khiter_t git_strmap_iter; ...@@ -38,6 +38,7 @@ typedef khiter_t git_strmap_iter;
#define git_strmap_has_data(h, idx) kh_exist(h, idx) #define git_strmap_has_data(h, idx) kh_exist(h, idx)
#define git_strmap_key(h, idx) kh_key(h, idx) #define git_strmap_key(h, idx) kh_key(h, idx)
#define git_strmap_set_key_at(h, idx, k) kh_val(h, idx) = k
#define git_strmap_value_at(h, idx) kh_val(h, idx) #define git_strmap_value_at(h, idx) kh_val(h, idx)
#define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v #define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_strmap_delete_at(h, idx) kh_del(str, h, idx) #define git_strmap_delete_at(h, idx) kh_del(str, h, idx)
......
...@@ -39,7 +39,7 @@ void test_core_oidmap__basic(void) ...@@ -39,7 +39,7 @@ void test_core_oidmap__basic(void)
pos = git_oidmap_put(map, &items[i].oid, &ret); pos = git_oidmap_put(map, &items[i].oid, &ret);
cl_assert(ret != 0); cl_assert(ret != 0);
git_oidmap_value_at(map, pos) = &items[i]; git_oidmap_set_value_at(map, pos, &items[i]);
} }
...@@ -93,7 +93,7 @@ void test_core_oidmap__hash_collision(void) ...@@ -93,7 +93,7 @@ void test_core_oidmap__hash_collision(void)
pos = git_oidmap_put(map, &items[i].oid, &ret); pos = git_oidmap_put(map, &items[i].oid, &ret);
cl_assert(ret != 0); cl_assert(ret != 0);
git_oidmap_value_at(map, pos) = &items[i]; git_oidmap_set_value_at(map, pos, &items[i]);
} }
......
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