summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1b32fd)
raw | patch | inline | side by side (parent: a1b32fd)
author | Junio C Hamano <gitster@pobox.com> | |
Sun, 22 Jun 2008 07:27:46 +0000 (00:27 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 22 Jun 2008 07:54:40 +0000 (00:54 -0700) |
It is dubious if it is cheaper to shift entries repeatedly using memmove()
to collect entries that needs to be written out in front of an array than
simply marking the entries to be skipped. In addition, the label called this
"tail optimization", but this obviously is not what people usually call
with that name.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to collect entries that needs to be written out in front of an array than
simply marking the entries to be skipped. In addition, the label called this
"tail optimization", but this obviously is not what people usually call
with that name.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-rerere.c | patch | blob | history |
diff --git a/builtin-rerere.c b/builtin-rerere.c
index addc5c73df0fd909d6e8e3aa799b73028819f0b7..0eec1f937321024187c185226764c39f6534017a 100644 (file)
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
{
int i;
for (i = 0; i < rr->nr; i++) {
- const char *path = rr->items[i].path;
- int length = strlen(path) + 1;
+ const char *path;
+ int length;
+ if (!rr->items[i].util)
+ continue;
+ path = rr->items[i].path;
+ length = strlen(path) + 1;
if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
write_in_full(out_fd, "\t", 1) != 1 ||
write_in_full(out_fd, path, length) != length)
if (!merge(name, path)) {
fprintf(stderr, "Resolved '%s' using "
"previous resolution.\n", path);
- goto tail_optimization;
+ goto mark_resolved;
}
}
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
copy_file(rr_path(name, "postimage"), path, 0666);
-tail_optimization:
- if (i < rr->nr - 1)
- memmove(rr->items + i,
- rr->items + i + 1,
- sizeof(rr->items[0]) * (rr->nr - i - 1));
- rr->nr--;
- i--;
+ mark_resolved:
+ rr->items[i].util = NULL;
}
return write_rr(rr, fd);