Re: [PATCH] git gc: Speed it up by 18% via faster hash comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 28, 2011 at 13:59, Erik Faye-Lund <kusmabite@xxxxxxxxx> wrote:
> diff --git a/cache.h b/cache.h
> index c730c58..8bc03c6 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -681,13 +681,17 @@ extern char *sha1_pack_name(const unsigned char *sha1);
> Â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);
> + Â Â Â /* early out for fast mis-match */
> + Â Â Â if (*sha1 != *sha2)
> + Â Â Â Â Â Â Â return *sha1 - *sha2;

Can one take advantage of common expression optimization here?
Like this:

+       if (*sha1 - *sha2)
+               return *sha1 - *sha2;
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]