summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4e8da19)
raw | patch | inline | side by side (parent: 4e8da19)
author | Nicolas Pitre <nico@cam.org> | |
Mon, 15 May 2006 17:47:16 +0000 (13:47 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 15 May 2006 19:32:13 +0000 (12:32 -0700) |
Avoid creating a delta index for objects with maximum depth since they
are not going to be used as delta base anyway. This also reduce peak
memory usage slightly as the current object's delta index is not useful
until the next object in the loop is considered for deltification. This
saves a bit more than 1% on CPU usage.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
are not going to be used as delta base anyway. This also reduce peak
memory usage slightly as the current object's delta index is not useful
until the next object in the loop is considered for deltification. This
saves a bit more than 1% on CPU usage.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
delta.h | patch | blob | history | |
pack-objects.c | patch | blob | history |
index 727ae30e9eb973b2bd4a512be78041fee40fa039..7b3f86d85f71e47d11c40a4abbcd9d9f499a6636 100644 (file)
--- a/delta.h
+++ b/delta.h
/*
* free_delta_index: free the index created by create_delta_index()
+ *
+ * Given pointer must be what create_delta_index() returned, or NULL.
*/
extern void free_delta_index(struct delta_index *index);
diff --git a/pack-objects.c b/pack-objects.c
index 526c090c619530a5fa61bc7530dee5002bab0ea1..b430b02cf7f5b39c97bc090634ef26346a022ade 100644 (file)
--- a/pack-objects.c
+++ b/pack-objects.c
if (entry->size < 50)
continue;
- if (n->index)
- free_delta_index(n->index);
+ free_delta_index(n->index);
+ n->index = NULL;
free(n->data);
n->entry = entry;
n->data = read_sha1_file(entry->sha1, type, &size);
if (size != entry->size)
die("object %s inconsistent object length (%lu vs %lu)",
sha1_to_hex(entry->sha1), size, entry->size);
- n->index = create_delta_index(n->data, size);
- if (!n->index)
- die("out of memory");
j = window;
while (--j > 0) {
*/
if (entry->delta && depth <= entry->depth)
continue;
+
+ n->index = create_delta_index(n->data, size);
+ if (!n->index)
+ die("out of memory");
+
idx++;
if (idx >= window)
idx = 0;
fputc('\n', stderr);
for (i = 0; i < window; ++i) {
- if (array[i].index)
- free_delta_index(array[i].index);
+ free_delta_index(array[i].index);
free(array[i].data);
}
free(array);