Merge branch 'rs/find-pack-entry-bisection' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)
Code clean-up.

* rs/find-pack-entry-bisection:
sha1_file: avoid comparison if no packed hash matches the first byte

sha1_file.c
index b7bb38b44590f3d4ab56c9e3cd4ea3ef434e7447..4c4a1f1ea364f08330c5a597ab0b63e84e954850 100644 (file)
@@ -2800,7 +2800,7 @@ off_t find_pack_entry_one(const unsigned char *sha1,
                return nth_packed_object_offset(p, pos);
        }
 
-       do {
+       while (lo < hi) {
                unsigned mi = (lo + hi) / 2;
                int cmp = hashcmp(index + mi * stride, sha1);
 
@@ -2813,7 +2813,7 @@ off_t find_pack_entry_one(const unsigned char *sha1,
                        hi = mi;
                else
                        lo = mi+1;
-       } while (lo < hi);
+       }
        return 0;
 }