hashcmp: use memcmp instead of open-coded loop
[gitweb.git] / cache.h
diff --git a/cache.h b/cache.h
index 900796c155be49d8c275c735edf1c7a2dabec70a..5688b263e4658dd69cd2ca799bbf13d58be39a42 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -962,14 +962,7 @@ extern const struct object_id null_oid;
 
 static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
 {
-       int i;
-
-       for (i = 0; i < GIT_SHA1_RAWSZ; i++, sha1++, sha2++) {
-               if (*sha1 != *sha2)
-                       return *sha1 - *sha2;
-       }
-
-       return 0;
+       return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
 }
 
 static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)