GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
{
- khiter_t k;
- k = kh_get(oid, idx->pack->idx_cache, id);
- return (k != kh_end(idx->pack->idx_cache));
+ return git_oidmap_exists(idx->pack->idx_cache, id);
}
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
static int impl__exists(git_odb_backend *backend, const git_oid *oid)
{
struct memory_packer_db *db = (struct memory_packer_db *)backend;
- khiter_t pos;
-
- pos = kh_get(oid, db->objects, oid);
- if (pos != kh_end(db->objects))
- return 1;
- return 0;
+ return git_oidmap_exists(db->objects, oid);
}
static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
#define git_oidmap_lookup_index(h, k) kh_get(oid, h, k)
#define git_oidmap_valid_index(h, idx) (idx != kh_end(h))
+#define git_oidmap_exists(h, k) (kh_get(oid, h, k) != kh_end(h))
+
#define git_oidmap_value_at(h, idx) kh_val(h, idx)
#define git_oidmap_insert(h, key, val, rval) do { \
/* If the object already exists in the hash table, then we don't
* have any work to do */
- pos = kh_get(oid, pb->object_ix, oid);
- if (pos != kh_end(pb->object_ix))
+ if (git_oidmap_exists(pb->object_ix, oid))
return 0;
if (pb->nr_objects >= pb->nr_alloc) {
return -1;
}
/* Add it to the cache if nobody else has */
- exists = kh_get(off, cache->entries, offset) != kh_end(cache->entries);
+ exists = git_offmap_exists(cache->entries, offset);
if (!exists) {
while (cache->memory_used + base->len > cache->memory_limit)
free_lowest_entry(cache);