rerere: stop looping unnecessarily
handle_cache() loops 3 times starting from an index entry that is unmerged, while ignoring an entry for a path that is different from what we are looking for. As the index is sorted, once we see a different path, we know we saw all stages for the path we are interested in. Just loop while we see the same path and then break, instead of continuing for 3 times. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
67711cdc39
commit
74444d4ec4
17
rerere.c
17
rerere.c
@ -329,24 +329,21 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
|
|||||||
return -1;
|
return -1;
|
||||||
pos = -pos - 1;
|
pos = -pos - 1;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
while (pos < active_nr) {
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
int j;
|
|
||||||
|
|
||||||
if (active_nr <= pos)
|
|
||||||
break;
|
|
||||||
ce = active_cache[pos++];
|
ce = active_cache[pos++];
|
||||||
if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
|
if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
|
||||||
continue;
|
break;
|
||||||
j = ce_stage(ce) - 1;
|
i = ce_stage(ce) - 1;
|
||||||
mmfile[j].ptr = read_sha1_file(ce->sha1, &type, &size);
|
mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size);
|
||||||
mmfile[j].size = size;
|
mmfile[i].size = size;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++)
|
||||||
if (!mmfile[i].ptr && !mmfile[i].size)
|
if (!mmfile[i].ptr && !mmfile[i].size)
|
||||||
mmfile[i].ptr = xstrdup("");
|
mmfile[i].ptr = xstrdup("");
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* NEEDSWORK: handle conflicts from merges with
|
* NEEDSWORK: handle conflicts from merges with
|
||||||
* merge.renormalize set, too
|
* merge.renormalize set, too
|
||||||
|
Loading…
Reference in New Issue
Block a user