diff options
author | Vicent Marti <tanoku@gmail.com> | 2013-08-14 10:34:07 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-08-14 10:34:07 +0200 |
commit | 59547ce77269e0667426327d9166aad0954bc686 (patch) | |
tree | 959fcacefb49daaa4f233f3bbc2a4694b98a38c2 | |
parent | e2164da5eb2d76129b8dae0b5ea2f7a606324fba (diff) | |
download | libgit2-59547ce77269e0667426327d9166aad0954bc686.tar.gz |
oid: Helper for old-school hashcmpvmg/no-lookup
-rw-r--r-- | src/oid.h | 23 | ||||
-rw-r--r-- | src/sha1_lookup.c | 2 |
2 files changed, 14 insertions, 11 deletions
@@ -9,17 +9,8 @@ #include "git2/oid.h" -/* - * Compare two oid structures. - * - * @param a first oid structure. - * @param b second oid structure. - * @return <0, 0, >0 if a < b, a == b, a > b. - */ -GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b) +GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2) { - const unsigned char *sha1 = a->id; - const unsigned char *sha2 = b->id; int i; for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) { @@ -30,4 +21,16 @@ GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b) return 0; } +/* + * Compare two oid structures. + * + * @param a first oid structure. + * @param b second oid structure. + * @return <0, 0, >0 if a < b, a == b, a > b. + */ +GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b) +{ + return git_oid__hashcmp(a->id, b->id); +} + #endif diff --git a/src/sha1_lookup.c b/src/sha1_lookup.c index 35149a18d..ce067caaa 100644 --- a/src/sha1_lookup.c +++ b/src/sha1_lookup.c @@ -187,7 +187,7 @@ int sha1_position(const void *table, do { unsigned mi = (lo + hi) / 2; - int cmp = git_oid__cmp((git_oid *)(base + mi * stride), (git_oid *)key); + int cmp = git_oid__hashcmp(base + mi * stride, key); if (!cmp) return mi; |