@@ -88,9 +88,8 @@ int git_idxmap_icase_resize(git_idxmap_icase *map, size_t size)
8888
8989void * git_idxmap_get (git_idxmap * map , const git_index_entry * key )
9090{
91- size_t idx = git_idxmap_lookup_index (map , key );
92- if (!git_idxmap_valid_index (map , idx ) ||
93- !git_idxmap_has_data (map , idx ))
91+ size_t idx = kh_get (idx , map , key );
92+ if (idx == kh_end (map ) || !kh_exist (map , idx ))
9493 return NULL ;
9594 return kh_val (map , idx );
9695}
@@ -131,9 +130,8 @@ int git_idxmap_icase_set(git_idxmap_icase *map, const git_index_entry *key, void
131130
132131void * git_idxmap_icase_get (git_idxmap_icase * map , const git_index_entry * key )
133132{
134- size_t idx = git_idxmap_icase_lookup_index (map , key );
135- if (!git_idxmap_icase_valid_index (map , idx ) ||
136- !git_idxmap_icase_has_data (map , idx ))
133+ size_t idx = kh_get (idxicase , map , key );
134+ if (idx == kh_end (map ) || !kh_exist (map , idx ))
137135 return NULL ;
138136 return kh_val (map , idx );
139137}
@@ -162,63 +160,18 @@ void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key,
162160
163161int git_idxmap_delete (git_idxmap * map , const git_index_entry * key )
164162{
165- khiter_t idx = git_idxmap_lookup_index ( map , key );
166- if (! git_idxmap_valid_index (map , idx ))
163+ khiter_t idx = kh_get ( idx , map , key );
164+ if (idx == kh_end (map ))
167165 return GIT_ENOTFOUND ;
168- git_idxmap_delete_at ( map , idx );
166+ kh_del ( idx , map , idx );
169167 return 0 ;
170168}
171169
172170int git_idxmap_icase_delete (git_idxmap_icase * map , const git_index_entry * key )
173171{
174- khiter_t idx = git_idxmap_icase_lookup_index ( map , key );
175- if (! git_idxmap_valid_index (( git_idxmap * ) map , idx ))
172+ khiter_t idx = kh_get ( idxicase , map , key );
173+ if (idx == kh_end ( map ))
176174 return GIT_ENOTFOUND ;
177- git_idxmap_icase_delete_at (map , idx );
178- return 0 ;
179- }
180-
181- size_t git_idxmap_lookup_index (git_idxmap * map , const git_index_entry * key )
182- {
183- return kh_get (idx , map , key );
184- }
185-
186- size_t git_idxmap_icase_lookup_index (git_idxmap_icase * map , const git_index_entry * key )
187- {
188- return kh_get (idxicase , map , key );
189- }
190-
191- void * git_idxmap_value_at (git_idxmap * map , size_t idx )
192- {
193- return kh_val (map , idx );
194- }
195-
196- int git_idxmap_valid_index (git_idxmap * map , size_t idx )
197- {
198- return idx != kh_end (map );
199- }
200-
201- int git_idxmap_icase_valid_index (git_idxmap_icase * map , size_t idx )
202- {
203- return idx != kh_end (map );
204- }
205-
206- int git_idxmap_has_data (git_idxmap * map , size_t idx )
207- {
208- return kh_exist (map , idx );
209- }
210-
211- int git_idxmap_icase_has_data (git_idxmap_icase * map , size_t idx )
212- {
213- return kh_exist (map , idx );
214- }
215-
216- void git_idxmap_delete_at (git_idxmap * map , size_t idx )
217- {
218- kh_del (idx , map , idx );
219- }
220-
221- void git_idxmap_icase_delete_at (git_idxmap_icase * map , size_t idx )
222- {
223175 kh_del (idxicase , map , idx );
176+ return 0 ;
224177}
0 commit comments