summaryrefslogtreecommitdiff
path: root/pack-objects.c
diff options
context:
space:
mode:
authorKarsten Blees <karsten.blees@gmail.com>2014-07-02 22:20:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-07 20:56:24 (GMT)
commit039dc71a7cb824300e242f8abc0fcb19dac93641 (patch)
tree9c38bb8655e0314cfe122b7355922c2413533825 /pack-objects.c
parent6f92e5ff3cdc813de8ef5327fd4bad492fb7d6c9 (diff)
downloadgit-039dc71a7cb824300e242f8abc0fcb19dac93641.zip
git-039dc71a7cb824300e242f8abc0fcb19dac93641.tar.gz
git-039dc71a7cb824300e242f8abc0fcb19dac93641.tar.bz2
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>
Diffstat (limited to 'pack-objects.c')
-rw-r--r--pack-objects.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 4f36c32..9992f3e 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -7,10 +7,9 @@ static uint32_t locate_object_entry_hash(struct packing_data *pdata,
const unsigned char *sha1,
int *found)
{
- uint32_t i, hash, mask = (pdata->index_size - 1);
+ uint32_t i, mask = (pdata->index_size - 1);
- memcpy(&hash, sha1, sizeof(uint32_t));
- i = hash & mask;
+ i = sha1hash(sha1) & mask;
while (pdata->index[i] > 0) {
uint32_t pos = pdata->index[i] - 1;