hashmap: convert sha1hash() to oidhash()
There are no callers left of sha1hash() that do not simply pass the "hash" member of a "struct object_id". Let's get rid of the outdated sha1-specific function and provide one that operates on the whole struct (even though the technique, taking the first few bytes of the hash, will remain the same). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
c0566d78aa
commit
d40abc8e95
@ -1,6 +1,8 @@
|
||||
#ifndef HASHMAP_H
|
||||
#define HASHMAP_H
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
/*
|
||||
* Generic implementation of hash-based key-value mappings.
|
||||
*
|
||||
@ -118,14 +120,14 @@ unsigned int memihash_cont(unsigned int hash_seed, const void *buf, size_t len);
|
||||
* the results will be different on big-endian and little-endian
|
||||
* platforms, so they should not be stored or transferred over the net.
|
||||
*/
|
||||
static inline unsigned int sha1hash(const unsigned char *sha1)
|
||||
static inline unsigned int oidhash(const struct object_id *oid)
|
||||
{
|
||||
/*
|
||||
* Equivalent to 'return *(unsigned int *)sha1;', but safe on
|
||||
* Equivalent to 'return *(unsigned int *)oid->hash;', but safe on
|
||||
* platforms that don't support unaligned reads.
|
||||
*/
|
||||
unsigned int hash;
|
||||
memcpy(&hash, sha1, sizeof(hash));
|
||||
memcpy(&hash, oid->hash, sizeof(hash));
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user