Skip to content

Commit 822a4d4

Browse files
committed
Merge branch 'jk/hashcmp-memcmp' into maint
Code clean-up. * jk/hashcmp-memcmp: hashcmp: use memcmp instead of open-coded loop
2 parents f35a1d7 + 0b00601 commit 822a4d4

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

cache.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -939,14 +939,7 @@ extern const struct object_id null_oid;
939939

940940
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
941941
{
942-
int i;
943-
944-
for (i = 0; i < GIT_SHA1_RAWSZ; i++, sha1++, sha2++) {
945-
if (*sha1 != *sha2)
946-
return *sha1 - *sha2;
947-
}
948-
949-
return 0;
942+
return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
950943
}
951944

952945
static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)

0 commit comments

Comments
 (0)