summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e5e0161)
raw | patch | inline | side by side (parent: e5e0161)
author | Nicolas Pitre <nico@cam.org> | |
Sun, 18 Mar 2007 01:13:57 +0000 (21:13 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 18 Mar 2007 22:36:59 +0000 (15:36 -0700) |
A malloc() + memcpy() will always be faster than mmap() +
malloc() + inflate(). If the data is already there it is
certainly better to copy it straight away.
With this patch below I can do 'git log drivers/scsi/ >
/dev/null' about 7% faster. I bet it might be even more on
those platforms with bad mmap() support.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
malloc() + inflate(). If the data is already there it is
certainly better to copy it straight away.
With this patch below I can do 'git log drivers/scsi/ >
/dev/null' about 7% faster. I bet it might be even more on
those platforms with bad mmap() support.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index a7e3a2a9f963ce1bee1f54f05eaa8852b2bd2347..ee64865b607c70ff42f851b91c19316ef90ce7b9 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
}
static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
- unsigned long *base_size, enum object_type *type)
+ unsigned long *base_size, enum object_type *type, int keep_cache)
{
void *ret;
unsigned long hash = pack_entry_hash(p, base_offset);
return unpack_entry(p, base_offset, type, base_size);
found_cache_entry:
- ent->data = NULL;
+ if (!keep_cache)
+ ent->data = NULL;
+ else {
+ ret = xmalloc(ent->size + 1);
+ memcpy(ret, ent->data, ent->size);
+ ((char *)ret)[ent->size] = 0;
+ }
*type = ent->type;
*base_size = ent->size;
return ret;
off_t base_offset;
base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset);
- base = cache_or_unpack_entry(p, base_offset, &base_size, type);
+ base = cache_or_unpack_entry(p, base_offset, &base_size, type, 0);
if (!base)
die("failed to read delta base object"
" at %"PRIuMAX" from %s",
if (!find_pack_entry(sha1, &e, NULL))
return NULL;
else
- return unpack_entry(e.p, e.offset, type, size);
+ return cache_or_unpack_entry(e.p, e.offset, size, type, 1);
}
/*