mirror of
https://github.com/git/git.git
synced 2026-01-08 01:11:04 +00:00
Merge branch 'jc/object-read-stream-fix'
Fix a performance regression in recently graduated topic. * jc/object-read-stream-fix: odb: do not use "blank" substitute for NULL
This commit is contained in:
@@ -426,7 +426,7 @@ int odb_source_loose_read_object_info(struct odb_source *source,
|
|||||||
unsigned long size_scratch;
|
unsigned long size_scratch;
|
||||||
enum object_type type_scratch;
|
enum object_type type_scratch;
|
||||||
|
|
||||||
if (oi->delta_base_oid)
|
if (oi && oi->delta_base_oid)
|
||||||
oidclr(oi->delta_base_oid, source->odb->repo->hash_algo);
|
oidclr(oi->delta_base_oid, source->odb->repo->hash_algo);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -437,13 +437,13 @@ int odb_source_loose_read_object_info(struct odb_source *source,
|
|||||||
* return value implicitly indicates whether the
|
* return value implicitly indicates whether the
|
||||||
* object even exists.
|
* object even exists.
|
||||||
*/
|
*/
|
||||||
if (!oi->typep && !oi->sizep && !oi->contentp) {
|
if (!oi || (!oi->typep && !oi->sizep && !oi->contentp)) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (!oi->disk_sizep && (flags & OBJECT_INFO_QUICK))
|
if ((!oi || !oi->disk_sizep) && (flags & OBJECT_INFO_QUICK))
|
||||||
return quick_has_loose(source->loose, oid) ? 0 : -1;
|
return quick_has_loose(source->loose, oid) ? 0 : -1;
|
||||||
if (stat_loose_object(source->loose, oid, &st, &path) < 0)
|
if (stat_loose_object(source->loose, oid, &st, &path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (oi->disk_sizep)
|
if (oi && oi->disk_sizep)
|
||||||
*oi->disk_sizep = st.st_size;
|
*oi->disk_sizep = st.st_size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
29
odb.c
29
odb.c
@@ -677,34 +677,31 @@ static int do_oid_object_info_extended(struct object_database *odb,
|
|||||||
const struct object_id *oid,
|
const struct object_id *oid,
|
||||||
struct object_info *oi, unsigned flags)
|
struct object_info *oi, unsigned flags)
|
||||||
{
|
{
|
||||||
static struct object_info blank_oi = OBJECT_INFO_INIT;
|
|
||||||
const struct cached_object *co;
|
const struct cached_object *co;
|
||||||
const struct object_id *real = oid;
|
const struct object_id *real = oid;
|
||||||
int already_retried = 0;
|
int already_retried = 0;
|
||||||
|
|
||||||
|
|
||||||
if (flags & OBJECT_INFO_LOOKUP_REPLACE)
|
if (flags & OBJECT_INFO_LOOKUP_REPLACE)
|
||||||
real = lookup_replace_object(odb->repo, oid);
|
real = lookup_replace_object(odb->repo, oid);
|
||||||
|
|
||||||
if (is_null_oid(real))
|
if (is_null_oid(real))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!oi)
|
|
||||||
oi = &blank_oi;
|
|
||||||
|
|
||||||
co = find_cached_object(odb, real);
|
co = find_cached_object(odb, real);
|
||||||
if (co) {
|
if (co) {
|
||||||
if (oi->typep)
|
if (oi) {
|
||||||
*(oi->typep) = co->type;
|
if (oi->typep)
|
||||||
if (oi->sizep)
|
*(oi->typep) = co->type;
|
||||||
*(oi->sizep) = co->size;
|
if (oi->sizep)
|
||||||
if (oi->disk_sizep)
|
*(oi->sizep) = co->size;
|
||||||
*(oi->disk_sizep) = 0;
|
if (oi->disk_sizep)
|
||||||
if (oi->delta_base_oid)
|
*(oi->disk_sizep) = 0;
|
||||||
oidclr(oi->delta_base_oid, odb->repo->hash_algo);
|
if (oi->delta_base_oid)
|
||||||
if (oi->contentp)
|
oidclr(oi->delta_base_oid, odb->repo->hash_algo);
|
||||||
*oi->contentp = xmemdupz(co->buf, co->size);
|
if (oi->contentp)
|
||||||
oi->whence = OI_CACHED;
|
*oi->contentp = xmemdupz(co->buf, co->size);
|
||||||
|
oi->whence = OI_CACHED;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2138,7 +2138,6 @@ int packfile_store_read_object_info(struct packfile_store *store,
|
|||||||
struct object_info *oi,
|
struct object_info *oi,
|
||||||
unsigned flags UNUSED)
|
unsigned flags UNUSED)
|
||||||
{
|
{
|
||||||
static struct object_info blank_oi = OBJECT_INFO_INIT;
|
|
||||||
struct pack_entry e;
|
struct pack_entry e;
|
||||||
int rtype;
|
int rtype;
|
||||||
|
|
||||||
@@ -2149,7 +2148,7 @@ int packfile_store_read_object_info(struct packfile_store *store,
|
|||||||
* We know that the caller doesn't actually need the
|
* We know that the caller doesn't actually need the
|
||||||
* information below, so return early.
|
* information below, so return early.
|
||||||
*/
|
*/
|
||||||
if (oi == &blank_oi)
|
if (!oi)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rtype = packed_object_info(store->odb->repo, e.p, e.offset, oi);
|
rtype = packed_object_info(store->odb->repo, e.p, e.offset, oi);
|
||||||
|
|||||||
Reference in New Issue
Block a user