Web lists-archives.com

Re: [PATCH] sha1_file: avoid comparison if no packed hash matches the first byte

On Wed, Aug 09, 2017 at 05:20:05AM -0400, Jeff King wrote:

> > I still wonder if we want to retire that conditional invocation of
> > sha1_entry_pos(), though.
> I think so. Digging in the list for it, almost every mention is either
> somebody asking "should we scrap this?" or somebody showing benchmarks
> in which it is slower than the normal lookup (and then somebody asking
> "should we scrap this" :) ).
> I just re-ran a simple benchmark and it is indeed slower. I also came
> across the hashcmp open-code-versus-memcmp discussion, which shows that
> the memcmp in recent glibc is much faster. That has been around long
> enough that it's probably worth switching to.

So here are two patches (on top of René's since there is otherwise a
minor textual conflict).

  [1/2]: sha1_file: drop experimental GIT_USE_LOOKUP search
  [2/2]: hashcmp: use memcmp instead of open-coded loop

 cache.h                           |   9 +-
 sha1-lookup.c                     | 216 --------------------------------------
 sha1_file.c                       |  11 --
 t/t5308-pack-detect-duplicates.sh |  11 +-
 t/test-lib.sh                     |   1 -
 5 files changed, 2 insertions(+), 246 deletions(-)