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
@ -242,14 +242,12 @@ struct file_similarity {
|
||||
|
||||
static unsigned int hash_filespec(struct diff_filespec *filespec)
|
||||
{
|
||||
unsigned int hash;
|
||||
if (!filespec->sha1_valid) {
|
||||
if (diff_populate_filespec(filespec, 0))
|
||||
return 0;
|
||||
hash_sha1_file(filespec->data, filespec->size, "blob", filespec->sha1);
|
||||
}
|
||||
memcpy(&hash, filespec->sha1, sizeof(hash));
|
||||
return hash;
|
||||
return sha1hash(filespec->sha1);
|
||||
}
|
||||
|
||||
static int find_identical_files(struct hashmap *srcs,
|
||||
|
Reference in New Issue
Block a user