Skip to content

Commit

Permalink
revision: append to list instead of insert and reverse
Browse files Browse the repository at this point in the history
By using commit_list_insert(), we added new items to the top of the
list and, since this is not the order we want, reversed it afterwards.
Simplify this process by adding new items at the bottom instead,
getting rid of the reversal step.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Apr 25, 2012
1 parent 89b5f1d commit 2e7da8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,7 @@ int prepare_revision_walk(struct rev_info *revs)
{
int nr = revs->pending.nr;
struct object_array_entry *e, *list;
struct commit_list **next = &revs->commits;

e = list = revs->pending.objects;
revs->pending.nr = 0;
Expand All @@ -2076,12 +2077,11 @@ int prepare_revision_walk(struct rev_info *revs)
if (commit) {
if (!(commit->object.flags & SEEN)) {
commit->object.flags |= SEEN;
commit_list_insert(commit, &revs->commits);
next = commit_list_append(commit, next);
}
}
e++;
}
commit_list_reverse(&revs->commits);
commit_list_sort_by_date(&revs->commits);
if (!revs->leak_pending)
free(list);
Expand Down

0 comments on commit 2e7da8e

Please sign in to comment.