mirror of
https://github.com/git/git.git
synced 2025-03-16 13:35:20 +00:00
pack-objects: thin pack micro-optimization.
Since we sort objects by type, hash, preferredness and then size, after we have a delta against preferred base, there is no point trying a delta with non-preferred base. This seems to save expensive calls to diff-delta and it also seems to save the output space as well. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
b19696c2e7
commit
b925410d10
@ -447,7 +447,7 @@ static int add_object_entry(const unsigned char *sha1, const char *name, int exc
|
|||||||
struct packed_git *p;
|
struct packed_git *p;
|
||||||
unsigned int found_offset = 0;
|
unsigned int found_offset = 0;
|
||||||
struct packed_git *found_pack = NULL;
|
struct packed_git *found_pack = NULL;
|
||||||
int ix;
|
int ix, status = 0;
|
||||||
|
|
||||||
if (!exclude) {
|
if (!exclude) {
|
||||||
for (p = packed_git; p; p = p->next) {
|
for (p = packed_git; p; p = p->next) {
|
||||||
@ -493,6 +493,7 @@ static int add_object_entry(const unsigned char *sha1, const char *name, int exc
|
|||||||
die("internal error in object hashing.");
|
die("internal error in object hashing.");
|
||||||
object_ix[-1 - ix] = idx + 1;
|
object_ix[-1 - ix] = idx + 1;
|
||||||
}
|
}
|
||||||
|
status = 1;
|
||||||
|
|
||||||
already_added:
|
already_added:
|
||||||
if (exclude)
|
if (exclude)
|
||||||
@ -503,7 +504,7 @@ static int add_object_entry(const unsigned char *sha1, const char *name, int exc
|
|||||||
entry->in_pack_offset = found_offset;
|
entry->in_pack_offset = found_offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_pbase_tree(struct tree_desc *tree)
|
static void add_pbase_tree(struct tree_desc *tree)
|
||||||
@ -521,7 +522,10 @@ static void add_pbase_tree(struct tree_desc *tree)
|
|||||||
continue;
|
continue;
|
||||||
if (sha1_object_info(sha1, type, &size))
|
if (sha1_object_info(sha1, type, &size))
|
||||||
continue;
|
continue;
|
||||||
add_object_entry(sha1, name, 1);
|
|
||||||
|
if (!add_object_entry(sha1, name, 1))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!strcmp(type, "tree")) {
|
if (!strcmp(type, "tree")) {
|
||||||
struct tree_desc sub;
|
struct tree_desc sub;
|
||||||
void *elem;
|
void *elem;
|
||||||
@ -543,8 +547,8 @@ static void add_preferred_base(unsigned char *sha1)
|
|||||||
tree.buf = elem;
|
tree.buf = elem;
|
||||||
if (!tree.buf)
|
if (!tree.buf)
|
||||||
return;
|
return;
|
||||||
add_object_entry(sha1, "", 1);
|
if (add_object_entry(sha1, "", 1))
|
||||||
add_pbase_tree(&tree);
|
add_pbase_tree(&tree);
|
||||||
free(elem);
|
free(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,7 +778,7 @@ static int try_delta(struct unpacked *cur, struct unpacked *old, unsigned max_de
|
|||||||
* already have a delta based on preferred
|
* already have a delta based on preferred
|
||||||
* one is pointless.
|
* one is pointless.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (!old_preferred)
|
else if (!old_preferred)
|
||||||
max_size = cur_entry->delta_size-1;
|
max_size = cur_entry->delta_size-1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user