mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
hashmap: factor out getting a hash code from a SHA1
Copying the first bytes of a SHA1 is duplicated in six places, however, the implications (the actual value would depend on the endianness of the platform) is documented only once. Add a properly documented API for this. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
6f92e5ff3c
commit
039dc71a7c
11
khash.h
11
khash.h
@@ -320,19 +320,12 @@ static const double __ac_HASH_UPPER = 0.77;
|
||||
code; \
|
||||
} }
|
||||
|
||||
static inline khint_t __kh_oid_hash(const unsigned char *oid)
|
||||
{
|
||||
khint_t hash;
|
||||
memcpy(&hash, oid, sizeof(hash));
|
||||
return hash;
|
||||
}
|
||||
|
||||
#define __kh_oid_cmp(a, b) (hashcmp(a, b) == 0)
|
||||
|
||||
KHASH_INIT(sha1, const unsigned char *, void *, 1, __kh_oid_hash, __kh_oid_cmp)
|
||||
KHASH_INIT(sha1, const unsigned char *, void *, 1, sha1hash, __kh_oid_cmp)
|
||||
typedef kh_sha1_t khash_sha1;
|
||||
|
||||
KHASH_INIT(sha1_pos, const unsigned char *, int, 1, __kh_oid_hash, __kh_oid_cmp)
|
||||
KHASH_INIT(sha1_pos, const unsigned char *, int, 1, sha1hash, __kh_oid_cmp)
|
||||
typedef kh_sha1_pos_t khash_sha1_pos;
|
||||
|
||||
#endif /* __AC_KHASH_H */
|
||||
|
||||
Reference in New Issue
Block a user