Skip to content

Commit 4ed43d1

Browse files
peffgitster
authored andcommitted
khash: drop broken oid_map typedef
Commit 5a8643e (khash: move oid hash table definition, 2019-02-19) added a khash "oid_map" type to match the existing "oid" type, which is a simple set (i.e., just keys, no values). But in setting up the khash_oid_map typedef, it accidentally referred to "kh_oid_t", which is the set type. Nobody noticed the breakage because there are not yet any callers; the type was added just as a match to the existing sha1 types (whose map type confusingly _is_ called khash_sha1, and it has no matching set type). We could easily fix this with s/oid/oid_map/ in the typedef. But let's take this a step further, and just drop the typedef entirely. These typedefs were added by 5a8643e to match the khash_sha1 typedefs. But the actual khash-derived type names are descriptive enough; this is just adding an extra layer of indirection. The khash names do not quite follow our usual style (e.g., they end in "_t"), but since we end up using other khash names (e.g., khiter_t, kh_get_oid()) anyway, just typedef-ing the struct name is not really helping much. And there are already many cases where we use the raw khash type names anyway (e.g., the "set" variant defined just above us does not have such a typedef!). So let's drop this typedef, and the matching oid_pos one (which actually _does_ have a user, but we can easily convert it). We'll leave the khash_sha1 typedef around. The ultimate fate of its callers should be conversion to kh_oid_map_t, so there's no point in going through the noise of changing the names now. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a378509 commit 4ed43d1

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

khash.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,7 @@ static inline int oid_equal(struct object_id a, struct object_id b)
345345
KHASH_INIT(oid, struct object_id, int, 0, oid_hash, oid_equal)
346346

347347
KHASH_INIT(oid_map, struct object_id, void *, 1, oid_hash, oid_equal)
348-
typedef kh_oid_t khash_oid_map;
349348

350349
KHASH_INIT(oid_pos, struct object_id, int, 1, oid_hash, oid_equal)
351-
typedef kh_oid_pos_t khash_oid_pos;
352350

353351
#endif /* __AC_KHASH_H */

pack-bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ struct include_data {
365365
static inline int bitmap_position_extended(struct bitmap_index *bitmap_git,
366366
const struct object_id *oid)
367367
{
368-
khash_oid_pos *positions = bitmap_git->ext_index.positions;
368+
kh_oid_pos_t *positions = bitmap_git->ext_index.positions;
369369
khiter_t pos = kh_get_oid_pos(positions, *oid);
370370

371371
if (pos < kh_end(positions)) {

0 commit comments

Comments
 (0)