Merge branch 'jt/skipping-negotiator-wo-recursion'
Rewrite a deep recursion in the skipping negotiator to use a loop with on-heap prio queue to avoid stack wastage. * jt/skipping-negotiator-wo-recursion: negotiator/skipping: avoid stack overflow
This commit is contained in:
commit
2f503ee0d7
@ -86,10 +86,14 @@ static int clear_marks(const char *refname, const struct object_id *oid,
|
|||||||
/*
|
/*
|
||||||
* Mark this SEEN commit and all its SEEN ancestors as COMMON.
|
* Mark this SEEN commit and all its SEEN ancestors as COMMON.
|
||||||
*/
|
*/
|
||||||
static void mark_common(struct data *data, struct commit *c)
|
static void mark_common(struct data *data, struct commit *seen_commit)
|
||||||
{
|
{
|
||||||
struct commit_list *p;
|
struct prio_queue queue = { NULL };
|
||||||
|
struct commit *c;
|
||||||
|
|
||||||
|
prio_queue_put(&queue, seen_commit);
|
||||||
|
while ((c = prio_queue_get(&queue))) {
|
||||||
|
struct commit_list *p;
|
||||||
if (c->object.flags & COMMON)
|
if (c->object.flags & COMMON)
|
||||||
return;
|
return;
|
||||||
c->object.flags |= COMMON;
|
c->object.flags |= COMMON;
|
||||||
@ -100,7 +104,8 @@ static void mark_common(struct data *data, struct commit *c)
|
|||||||
return;
|
return;
|
||||||
for (p = c->parents; p; p = p->next) {
|
for (p = c->parents; p; p = p->next) {
|
||||||
if (p->item->object.flags & SEEN)
|
if (p->item->object.flags & SEEN)
|
||||||
mark_common(data, p->item);
|
prio_queue_put(&queue, p->item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user