mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-23 09:10:46 +00:00
khash: use git_map_exists
where applicable
This commit is contained in:
parent
9694d9ba79
commit
036daa59e9
@ -333,9 +333,7 @@ on_error:
|
|||||||
|
|
||||||
GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
|
GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
|
||||||
{
|
{
|
||||||
khiter_t k;
|
return git_oidmap_exists(idx->pack->idx_cache, id);
|
||||||
k = kh_get(oid, idx->pack->idx_cache, id);
|
|
||||||
return (k != kh_end(idx->pack->idx_cache));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
|
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
|
||||||
|
@ -72,13 +72,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
|
|||||||
static int impl__exists(git_odb_backend *backend, const git_oid *oid)
|
static int impl__exists(git_odb_backend *backend, const git_oid *oid)
|
||||||
{
|
{
|
||||||
struct memory_packer_db *db = (struct memory_packer_db *)backend;
|
struct memory_packer_db *db = (struct memory_packer_db *)backend;
|
||||||
khiter_t pos;
|
|
||||||
|
|
||||||
pos = kh_get(oid, db->objects, oid);
|
return git_oidmap_exists(db->objects, oid);
|
||||||
if (pos != kh_end(db->objects))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
|
static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
|
||||||
|
@ -36,6 +36,8 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
|
|||||||
#define git_oidmap_lookup_index(h, k) kh_get(oid, h, k)
|
#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_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_value_at(h, idx) kh_val(h, idx)
|
||||||
|
|
||||||
#define git_oidmap_insert(h, key, val, rval) do { \
|
#define git_oidmap_insert(h, key, val, rval) do { \
|
||||||
|
@ -216,8 +216,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
|
|||||||
|
|
||||||
/* If the object already exists in the hash table, then we don't
|
/* If the object already exists in the hash table, then we don't
|
||||||
* have any work to do */
|
* have any work to do */
|
||||||
pos = kh_get(oid, pb->object_ix, oid);
|
if (git_oidmap_exists(pb->object_ix, oid))
|
||||||
if (pos != kh_end(pb->object_ix))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (pb->nr_objects >= pb->nr_alloc) {
|
if (pb->nr_objects >= pb->nr_alloc) {
|
||||||
|
@ -164,7 +164,7 @@ static int cache_add(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Add it to the cache if nobody else has */
|
/* 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) {
|
if (!exists) {
|
||||||
while (cache->memory_used + base->len > cache->memory_limit)
|
while (cache->memory_used + base->len > cache->memory_limit)
|
||||||
free_lowest_entry(cache);
|
free_lowest_entry(cache);
|
||||||
|
Loading…
Reference in New Issue
Block a user