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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/src/idxmap.c b/src/idxmap.c
index d7aa4ea..e75887c 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 ce9f084..76170ef 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