Commit 577aeef7e96a76faaabf731d0762b5b723ea6c4b

Edward Thomson 2017-08-14T22:02:26

Merge pull request #4328 from libgit2/peff/hashcmp-is-memcmp oid: use memcmp in git_oid__hashcmp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/oid.h b/src/oid.h
index 922a2a3..ca6c92c 100644
--- a/src/oid.h
+++ b/src/oid.h
@@ -22,14 +22,7 @@ char *git_oid_allocfmt(const git_oid *id);
 
 GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2)
 {
-	int i;
-
-	for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
-		if (*sha1 != *sha2)
-			return *sha1 - *sha2;
-	}
-
-	return 0;
+	return memcmp(sha1, sha2, GIT_OID_RAWSZ);
 }
 
 /*