Skip to content

Commit 5a8643e

Browse files
bk2204gitster
authored andcommitted
khash: move oid hash table definition
Move the oid khash table definition to khash.h and define a typedef for it, similar to the one we have for unsigned char pointers. Define variants that are maps as well. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 76c2389 commit 5a8643e

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

khash.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,22 @@ typedef kh_sha1_t khash_sha1;
332332
KHASH_INIT(sha1_pos, const unsigned char *, int, 1, sha1hash, __kh_oid_cmp)
333333
typedef kh_sha1_pos_t khash_sha1_pos;
334334

335+
static inline unsigned int oid_hash(struct object_id oid)
336+
{
337+
return sha1hash(oid.hash);
338+
}
339+
340+
static inline int oid_equal(struct object_id a, struct object_id b)
341+
{
342+
return oideq(&a, &b);
343+
}
344+
345+
KHASH_INIT(oid, struct object_id, int, 0, oid_hash, oid_equal)
346+
347+
KHASH_INIT(oid_map, struct object_id, void *, 1, oid_hash, oid_equal)
348+
typedef kh_oid_t khash_oid_map;
349+
350+
KHASH_INIT(oid_pos, struct object_id, int, 1, oid_hash, oid_equal)
351+
typedef kh_oid_pos_t khash_oid_pos;
352+
335353
#endif /* __AC_KHASH_H */

oidset.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@
1616
* table overhead.
1717
*/
1818

19-
static inline unsigned int oid_hash(struct object_id oid)
20-
{
21-
return sha1hash(oid.hash);
22-
}
23-
24-
static inline int oid_equal(struct object_id a, struct object_id b)
25-
{
26-
return oideq(&a, &b);
27-
}
28-
29-
KHASH_INIT(oid, struct object_id, int, 0, oid_hash, oid_equal)
30-
3119
/**
3220
* A single oidset; should be zero-initialized (or use OIDSET_INIT).
3321
*/

0 commit comments

Comments
 (0)