]> git.ipfire.org Git - thirdparty/git.git/blobdiff - cache.h
Git 2.19.1
[thirdparty/git.git] / cache.h
diff --git a/cache.h b/cache.h
index b1fd3d58ab20b6fd4460c6475c0eb0390c3ab9ac..4d014541ab7bc7692919c871a5306543bbf361c5 100644 (file)
--- 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);
 }