Skip to content

Commit 86ef236

Browse files
committed
Merge branch 'jk/hashcmp-optim-for-2.19'
Partially revert the support for multiple hash functions to regain hash comparison performance; we'd think of a way to do this better in the next cycle. * jk/hashcmp-optim-for-2.19: hashcmp: assert constant hash size
2 parents 99fb11d + 183a638 commit 86ef236

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cache.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,16 @@ extern const struct object_id null_oid;
10231023

10241024
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
10251025
{
1026+
/*
1027+
* This is a temporary optimization hack. By asserting the size here,
1028+
* we let the compiler know that it's always going to be 20, which lets
1029+
* it turn this fixed-size memcmp into a few inline instructions.
1030+
*
1031+
* This will need to be extended or ripped out when we learn about
1032+
* hashes of different sizes.
1033+
*/
1034+
if (the_hash_algo->rawsz != 20)
1035+
BUG("hash size not yet supported by hashcmp");
10261036
return memcmp(sha1, sha2, the_hash_algo->rawsz);
10271037
}
10281038

0 commit comments

Comments
 (0)