@@ -50,9 +50,8 @@ size_t git_oidmap_size(git_oidmap *map)
5050
5151void * git_oidmap_get (git_oidmap * map , const git_oid * key )
5252{
53- size_t idx = git_oidmap_lookup_index (map , key );
54- if (!git_oidmap_valid_index (map , idx ) ||
55- !git_oidmap_has_data (map , idx ))
53+ size_t idx = kh_get (oid , map , key );
54+ if (idx == kh_end (map ) || !kh_exist (map , idx ))
5655 return NULL ;
5756 return kh_val (map , idx );
5857}
@@ -76,10 +75,10 @@ int git_oidmap_set(git_oidmap *map, const git_oid *key, void *value)
7675
7776int git_oidmap_delete (git_oidmap * map , const git_oid * key )
7877{
79- khiter_t idx = git_oidmap_lookup_index ( map , key );
80- if (! git_oidmap_valid_index (map , idx ))
78+ khiter_t idx = kh_get ( oid , map , key );
79+ if (idx == kh_end (map ))
8180 return GIT_ENOTFOUND ;
82- git_oidmap_delete_at ( map , idx );
81+ kh_del ( oid , map , idx );
8382 return 0 ;
8483}
8584
@@ -92,84 +91,17 @@ int git_oidmap_iterate(void **value, git_oidmap *map, size_t *iter, const git_oi
9291{
9392 size_t i = * iter ;
9493
95- while (i < git_oidmap_end ( map ) && !git_oidmap_has_data (map , i ))
94+ while (i < map -> n_buckets && !kh_exist (map , i ))
9695 i ++ ;
9796
98- if (i >= git_oidmap_end ( map ) )
97+ if (i >= map -> n_buckets )
9998 return GIT_ITEROVER ;
10099
101100 if (key )
102- * key = git_oidmap_key (map , i );
101+ * key = kh_key (map , i );
103102 if (value )
104- * value = git_oidmap_value_at (map , i );
103+ * value = kh_value (map , i );
105104 * iter = ++ i ;
106105
107106 return 0 ;
108107}
109-
110- size_t git_oidmap_lookup_index (git_oidmap * map , const git_oid * key )
111- {
112- return kh_get (oid , map , key );
113- }
114-
115- int git_oidmap_valid_index (git_oidmap * map , size_t idx )
116- {
117- return idx != kh_end (map );
118- }
119-
120- int git_oidmap_has_data (git_oidmap * map , size_t idx )
121- {
122- return kh_exist (map , idx );
123- }
124-
125- const git_oid * git_oidmap_key (git_oidmap * map , size_t idx )
126- {
127- return kh_key (map , idx );
128- }
129-
130- void git_oidmap_set_key_at (git_oidmap * map , size_t idx , git_oid * key )
131- {
132- kh_key (map , idx ) = key ;
133- }
134-
135- void * git_oidmap_value_at (git_oidmap * map , size_t idx )
136- {
137- return kh_val (map , idx );
138- }
139-
140- void git_oidmap_set_value_at (git_oidmap * map , size_t idx , void * value )
141- {
142- kh_val (map , idx ) = value ;
143- }
144-
145- void git_oidmap_delete_at (git_oidmap * map , size_t idx )
146- {
147- kh_del (oid , map , idx );
148- }
149-
150- int git_oidmap_put (git_oidmap * map , const git_oid * key , int * err )
151- {
152- return kh_put (oid , map , key , err );
153- }
154-
155- void git_oidmap_insert (git_oidmap * map , const git_oid * key , void * value , int * rval )
156- {
157- khiter_t idx = kh_put (oid , map , key , rval );
158-
159- if ((* rval ) >= 0 ) {
160- if ((* rval ) == 0 )
161- kh_key (map , idx ) = key ;
162- kh_val (map , idx ) = value ;
163- }
164- }
165-
166- size_t git_oidmap_begin (git_oidmap * map )
167- {
168- GIT_UNUSED (map );
169- return 0 ;
170- }
171-
172- size_t git_oidmap_end (git_oidmap * map )
173- {
174- return map -> n_buckets ;
175- }
0 commit comments