summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-08-27 14:33:50 -0700
committerJunio C Hamano <gitster@pobox.com>2018-08-27 14:33:50 -0700
commit86ef236c989285954384cccfd9cea847f034143c (patch)
treec0145dccb1a86f00710ef12fb92002f660d27dba
parent99fb11d15b983abdda39b5bd5d16736c1550fe43 (diff)
parent183a638b7daf47dde1b62cc8f8a00eb3e12983e7 (diff)
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
-rw-r--r--cache.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index b1fd3d58ab..4d014541ab 100644
--- a/cache.h
+++ b/cache.h
@@ -1023,6 +1023,16 @@ extern const struct object_id null_oid;
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
{
+ /*
+ * This is a temporary optimization hack. By asserting the size here,
+ * we let the compiler know that it's always going to be 20, which lets
+ * it turn this fixed-size memcmp into a few inline instructions.
+ *
+ * This will need to be extended or ripped out when we learn about
+ * hashes of different sizes.
+ */
+ if (the_hash_algo->rawsz != 20)
+ BUG("hash size not yet supported by hashcmp");
return memcmp(sha1, sha2, the_hash_algo->rawsz);
}