sha1_file: avoid comparison if no packed hash matches the first byte
[gitweb.git] / sha1_file.c
index 7a4f8f8661a94ed9381e1297118c0de9e90c8c97..3047ee04f1ba50967836ba318a0b96e96d5962b4 100644 (file)
@@ -2526,7 +2526,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);
 
@@ -2539,7 +2539,7 @@ off_t find_pack_entry_one(const unsigned char *sha1,
                        hi = mi;
                else
                        lo = mi+1;
-       } while (lo < hi);
+       }
        return 0;
 }
 
@@ -3231,6 +3231,11 @@ int has_object_file(const struct object_id *oid)
        return has_sha1_file(oid->hash);
 }
 
+int has_object_file_with_flags(const struct object_id *oid, int flags)
+{
+       return has_sha1_file_with_flags(oid->hash, flags);
+}
+
 static void check_tree(const void *buf, size_t size)
 {
        struct tree_desc desc;