revision: append to list instead of insert and reverse
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Wed, 25 Apr 2012 20:35:41 +0000 (22:35 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2012 21:51:19 +0000 (14:51 -0700)
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>
revision.c

index 92095f5fcbb4454b3d605d2cdd6c9a1567498562..c1934ba3cace9e09fcf49fe92827c57c47e91473 100644 (file)
@@ -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;
@@ -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);