summaryrefslogtreecommitdiff
path: root/src/oidmap.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-12-01 08:59:24 +0100
committerPatrick Steinhardt <ps@pks.im>2019-02-15 13:16:48 +0100
commitc50a8ac2c734e4301223e39e4ddce98e6c368294 (patch)
tree85ad3a57e06b9405e7b525d4ca361cf9c137e7fd /src/oidmap.c
parent84a089da3701db370b2c77e6866abe3a5065c542 (diff)
downloadlibgit2-c50a8ac2c734e4301223e39e4ddce98e6c368294.tar.gz
maps: use high-level function to check existence of keys
Some callers were still using the tightly-coupled pattern of `lookup_index` and `valid_index` to verify that an entry exists in a map. Instead, use the more high-level `exists` functions to decouple map users from its implementation.
Diffstat (limited to 'src/oidmap.c')
-rw-r--r--src/oidmap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/oidmap.c b/src/oidmap.c
index d96551f9a..47a023f99 100644
--- a/src/oidmap.c
+++ b/src/oidmap.c
@@ -83,6 +83,11 @@ int git_oidmap_delete(git_oidmap *map, const git_oid *key)
return 0;
}
+int git_oidmap_exists(git_oidmap *map, const git_oid *key)
+{
+ return kh_get(oid, map, key) != kh_end(map);
+}
+
size_t git_oidmap_lookup_index(git_oidmap *map, const git_oid *key)
{
return kh_get(oid, map, key);
@@ -93,11 +98,6 @@ int git_oidmap_valid_index(git_oidmap *map, size_t idx)
return idx != kh_end(map);
}
-int git_oidmap_exists(git_oidmap *map, const git_oid *key)
-{
- return kh_get(oid, map, key) != kh_end(map);
-}
-
int git_oidmap_has_data(git_oidmap *map, size_t idx)
{
return kh_exist(map, idx);