Re: [ANNOUNCE] Git v2.19.0-rc0
- From
Jeff King <peff@peff.net>
- Date
- Aug 22, 2018, 15:24 UTC
- Message-ID
- <20180822152453.GD32630@sigill.intra.peff.net>
- In-Reply-To
- <459f138f-78ba-6465-0f2b-b2419bbc36ff@gmail.com>
On Wed, Aug 22, 2018 at 10:28:56AM -0400, Derrick Stolee wrote:
Show 24 quoted lines
> In my testing, I've had the best luck with this change:
>
> diff --git a/cache.h b/cache.h
> index b1fd3d58ab..6c8b51c390 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -1023,7 +1023,14 @@ extern const struct object_id null_oid;
>
> static inline int hashcmp(const unsigned char *sha1, const unsigned char
> *sha2)
> {
> - return memcmp(sha1, sha2, the_hash_algo->rawsz);
> + switch (the_hash_algo->rawsz) {
> + case 20:
> + return memcmp(sha1, sha2, 20);
> + case 32:
> + return memcmp(sha1, sha2, 32);
> + default:
> + assert(0);
> + }
> }
>
> The fact that '20' and '32' are constants here may be helpful to the
> compiler. Can someone else test the perf?I tested that one last night (and just re-tested it now to be sure). It seems to just generate two separate calls to memcmp, with no speed improvement.
-Peff