]> git.ipfire.org Git - thirdparty/git.git/commit - sha1-name.c
sha1_name: unroll len loop in find_unique_abbrev_r()
authorDerrick Stolee <dstolee@microsoft.com>
Sun, 8 Oct 2017 18:49:40 +0000 (14:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Oct 2017 00:26:03 +0000 (09:26 +0900)
commit5b20ace6a81e5fe1366b07c51b1f577f356a20ff
tree25979ec9b5986984484302bd56f832572a021d85
parent1af8b013099329336343f89c871f6be2cfbec4f1
sha1_name: unroll len loop in find_unique_abbrev_r()

Unroll the while loop inside find_unique_abbrev_r to avoid iterating
through all loose objects and packfiles multiple times when the short
name is longer than the predicted length.

Instead, inspect each object that collides with the estimated
abbreviation to find the longest common prefix.

The focus of this change is to refactor the existing method in a way
that clearly does not change the current behavior. In some cases, the
new method is slower than the previous method. Later changes will
correct all performance loss.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c