summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e923eae)
raw | patch | inline | side by side (parent: e923eae)
author | Ingo Molnar <mingo@elte.hu> | |
Thu, 28 Apr 2011 10:19:02 +0000 (12:19 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 28 Apr 2011 20:18:30 +0000 (13:18 -0700) |
This is reported to speed "git gc" by 18%.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history |
index d478eff1f323f25a474cf019e0de2254c5ff0360..57b297c08b9a5e2f98ca5514c397936ddaf79274 100644 (file)
--- a/cache.h
+++ b/cache.h
extern char *sha1_pack_index_name(const unsigned char *sha1);
extern const char *find_unique_abbrev(const unsigned char *sha1, int);
extern const unsigned char null_sha1[20];
-static inline int is_null_sha1(const unsigned char *sha1)
+
+static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
{
- return !memcmp(sha1, null_sha1, 20);
+ int i;
+
+ for (i = 0; i < 20; i++, sha1++, sha2++) {
+ if (*sha1 != *sha2)
+ return *sha1 - *sha2;
+ }
+
+ return 0;
}
-static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
+
+static inline int is_null_sha1(const unsigned char *sha1)
{
- return memcmp(sha1, sha2, 20);
+ return !hashcmp(sha1, null_sha1);
}
+
static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
{
memcpy(sha_dst, sha_src, 20);