diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2019-08-18 20:04:14 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-08-19 15:04:58 -0700 |
commit | e84f3572bd9160f281629bb2a098b35ea87c10e1 (patch) | |
tree | ac03ddcc318e34be8e8efa0a6ce16dc7b33001c7 /sha1-lookup.c | |
parent | fe9fec45f68e0d9850bf13da57b3e7a99fc33444 (diff) | |
download | git-e84f3572bd9160f281629bb2a098b35ea87c10e1.tar.gz |
sha1-lookup: switch hard-coded constants to the_hash_algo
Switch a hard-coded 18 to be a reference to the_hash_algo. Rename the
sha1 parameter to be called hash instead.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-lookup.c')
-rw-r--r-- | sha1-lookup.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sha1-lookup.c b/sha1-lookup.c index 796ab68da8..93d9af0805 100644 --- a/sha1-lookup.c +++ b/sha1-lookup.c @@ -50,7 +50,7 @@ static uint32_t take2(const unsigned char *sha1) * The sha1 of element i (between 0 and nr - 1) should be returned * by "fn(i, table)". */ -int sha1_pos(const unsigned char *sha1, void *table, size_t nr, +int sha1_pos(const unsigned char *hash, void *table, size_t nr, sha1_access_fn fn) { size_t hi = nr; @@ -63,10 +63,10 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, if (nr != 1) { size_t lov, hiv, miv, ofs; - for (ofs = 0; ofs < 18; ofs += 2) { + for (ofs = 0; ofs < the_hash_algo->rawsz - 2; ofs += 2) { lov = take2(fn(0, table) + ofs); hiv = take2(fn(nr - 1, table) + ofs); - miv = take2(sha1 + ofs); + miv = take2(hash + ofs); if (miv < lov) return -1; if (hiv < miv) @@ -88,7 +88,7 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, do { int cmp; - cmp = hashcmp(fn(mi, table), sha1); + cmp = hashcmp(fn(mi, table), hash); if (!cmp) return mi; if (cmp > 0) |