diff options
author | Junio C Hamano <junkio@cox.net> | 2006-03-19 13:43:42 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-03-19 13:43:42 -0800 |
commit | 67686d95044e56475669ff1306448e41a794a865 (patch) | |
tree | d8565eb74edeb732cd1efb4b68bbc242a7e7d118 /sha1_file.c | |
parent | 2b1c0ef2e5d103efacb535f32fb142114490dc33 (diff) | |
download | git-67686d95044e56475669ff1306448e41a794a865.tar.gz git-67686d95044e56475669ff1306448e41a794a865.tar.xz |
unpack_delta_entry(): reduce memory footprint.
Currently we unpack the delta data from the pack and then unpack
the base object to apply that delta data to it. When getting an
object that is deeply deltified, we can reduce memory footprint
by unpacking the base object first and then unpacking the delta
data, because we will need to keep at most one delta data in
memory that way.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sha1_file.c b/sha1_file.c index a80d849f1..58edec0bb 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -973,6 +973,16 @@ static void *unpack_delta_entry(unsigned char *base_sha1, if (left < 20) die("truncated pack file"); + + /* The base entry _must_ be in the same pack */ + if (!find_pack_entry_one(base_sha1, &base_ent, p)) + die("failed to find delta-pack base object %s", + sha1_to_hex(base_sha1)); + base = unpack_entry_gently(&base_ent, type, &base_size); + if (!base) + die("failed to read delta-pack base object %s", + sha1_to_hex(base_sha1)); + data = base_sha1 + 20; data_size = left - 20; delta_data = xmalloc(delta_size); @@ -990,14 +1000,6 @@ static void *unpack_delta_entry(unsigned char *base_sha1, if ((st != Z_STREAM_END) || stream.total_out != delta_size) die("delta data unpack failed"); - /* The base entry _must_ be in the same pack */ - if (!find_pack_entry_one(base_sha1, &base_ent, p)) - die("failed to find delta-pack base object %s", - sha1_to_hex(base_sha1)); - base = unpack_entry_gently(&base_ent, type, &base_size); - if (!base) - die("failed to read delta-pack base object %s", - sha1_to_hex(base_sha1)); result = patch_delta(base, base_size, delta_data, delta_size, &result_size); |