summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-12-01 10:54:57 +0100
committerPatrick Steinhardt <ps@pks.im>2019-02-15 13:16:49 +0100
commitdf42f3689bb9345438fba18178f8e4fc61e631dd (patch)
tree0aa5caa80e20e52b9d9ad99de0445fb02bc61a0a
parentbd66925a615f3adaf803455693b0b0c79a50ea4c (diff)
downloadlibgit2-df42f3689bb9345438fba18178f8e4fc61e631dd.tar.gz
idxmap: remove legacy low-level interface
Remove the low-level interface that was exposing implementation details of `git_idxmap` to callers. From now on, only the high-level functions shall be used to retrieve or modify values of a map. Adjust remaining existing callers.
-rw-r--r--src/idxmap.c67
-rw-r--r--src/idxmap.h14
2 files changed, 10 insertions, 71 deletions
diff --git a/src/idxmap.c b/src/idxmap.c
index d7aa4ea6b..e75887cfd 100644
--- a/src/idxmap.c
+++ b/src/idxmap.c
@@ -88,9 +88,8 @@ int git_idxmap_icase_resize(git_idxmap_icase *map, size_t size)
void *git_idxmap_get(git_idxmap *map, const git_index_entry *key)
{
- size_t idx = git_idxmap_lookup_index(map, key);
- if (!git_idxmap_valid_index(map, idx) ||
- !git_idxmap_has_data(map, idx))
+ size_t idx = kh_get(idx, map, key);
+ if (idx == kh_end(map) || !kh_exist(map, idx))
return NULL;
return kh_val(map, idx);
}
@@ -131,9 +130,8 @@ int git_idxmap_icase_set(git_idxmap_icase *map, const git_index_entry *key, void
void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key)
{
- size_t idx = git_idxmap_icase_lookup_index(map, key);
- if (!git_idxmap_icase_valid_index(map, idx) ||
- !git_idxmap_icase_has_data(map, idx))
+ size_t idx = kh_get(idxicase, map, key);
+ if (idx == kh_end(map) || !kh_exist(map, idx))
return NULL;
return kh_val(map, idx);
}
@@ -162,63 +160,18 @@ void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key,
int git_idxmap_delete(git_idxmap *map, const git_index_entry *key)
{
- khiter_t idx = git_idxmap_lookup_index(map, key);
- if (!git_idxmap_valid_index(map, idx))
+ khiter_t idx = kh_get(idx, map, key);
+ if (idx == kh_end(map))
return GIT_ENOTFOUND;
- git_idxmap_delete_at(map, idx);
+ kh_del(idx, map, idx);
return 0;
}
int git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key)
{
- khiter_t idx = git_idxmap_icase_lookup_index(map, key);
- if (!git_idxmap_valid_index((git_idxmap *)map, idx))
+ khiter_t idx = kh_get(idxicase, map, key);
+ if (idx == kh_end(map))
return GIT_ENOTFOUND;
- git_idxmap_icase_delete_at(map, idx);
- return 0;
-}
-
-size_t git_idxmap_lookup_index(git_idxmap *map, const git_index_entry *key)
-{
- return kh_get(idx, map, key);
-}
-
-size_t git_idxmap_icase_lookup_index(git_idxmap_icase *map, const git_index_entry *key)
-{
- return kh_get(idxicase, map, key);
-}
-
-void *git_idxmap_value_at(git_idxmap *map, size_t idx)
-{
- return kh_val(map, idx);
-}
-
-int git_idxmap_valid_index(git_idxmap *map, size_t idx)
-{
- return idx != kh_end(map);
-}
-
-int git_idxmap_icase_valid_index(git_idxmap_icase *map, size_t idx)
-{
- return idx != kh_end(map);
-}
-
-int git_idxmap_has_data(git_idxmap *map, size_t idx)
-{
- return kh_exist(map, idx);
-}
-
-int git_idxmap_icase_has_data(git_idxmap_icase *map, size_t idx)
-{
- return kh_exist(map, idx);
-}
-
-void git_idxmap_delete_at(git_idxmap *map, size_t idx)
-{
- kh_del(idx, map, idx);
-}
-
-void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx)
-{
kh_del(idxicase, map, idx);
+ return 0;
}
diff --git a/src/idxmap.h b/src/idxmap.h
index ce9f084ef..76170ef32 100644
--- a/src/idxmap.h
+++ b/src/idxmap.h
@@ -174,18 +174,4 @@ int git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
*/
int git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
-void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval);
-void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key, void *value, int *rval);
-
-size_t git_idxmap_lookup_index(git_idxmap *map, const git_index_entry *key);
-size_t git_idxmap_icase_lookup_index(git_idxmap_icase *map, const git_index_entry *key);
-void *git_idxmap_value_at(git_idxmap *map, size_t idx);
-int git_idxmap_valid_index(git_idxmap *map, size_t idx);
-int git_idxmap_icase_valid_index(git_idxmap_icase *map, size_t idx);
-int git_idxmap_has_data(git_idxmap *map, size_t idx);
-int git_idxmap_icase_has_data(git_idxmap_icase *map, size_t idx);
-
-void git_idxmap_delete_at(git_idxmap *map, size_t idx);
-void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
-
#endif