get_revision(): do not dig deeper when we know we are at the end.
This resurrects the special casing for "rev-list -n 1" which avoided reading parents unnecessarily. Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Mar 5, 2006 at 09:53 UTC
ea5ed3abce724725360be88663cec1add7547d46
1 file changed
+11
-7
revision.c
+11
-7
@@ -684,13 +684,11 @@ static void rewrite_parents(struct commit *commit)
684
struct commit *get_revision(struct rev_info *revs)
685
{
686
struct commit_list *list = revs->commits;
687
- struct commit *commit;
687
688
if (!list)
689
return NULL;
690
691
/* Check the max_count ... */
693
- commit = list->item;
692
switch (revs->max_count) {
693
case -1:
694
break;
@@ -701,22 +699,28 @@ struct commit *get_revision(struct rev_info *revs)
699
}
700
701
do {
704
- commit = pop_most_recent_commit(&revs->commits, SEEN);
702
+ struct commit *commit = revs->commits->item;
703
+
704
if (commit->object.flags & (UNINTERESTING|SHOWN))
706
- continue;
705
+ goto next;
706
if (revs->min_age != -1 && (commit->date > revs->min_age))
708
- continue;
707
+ goto next;
708
if (revs->max_age != -1 && (commit->date < revs->max_age))
709
return NULL;
710
if (revs->no_merges && commit->parents && commit->parents->next)
712
- continue;
711
+ goto next;
712
if (revs->paths && revs->dense) {
713
if (!(commit->object.flags & TREECHANGE))
715
- continue;
714
+ goto next;
715
rewrite_parents(commit);
716
}
717
+ /* More to go? */
718
+ if (revs->max_count)
719
+ pop_most_recent_commit(&revs->commits, SEEN);
720
commit->object.flags |= SHOWN;
721
return commit;
722
+next:
723
+ pop_most_recent_commit(&revs->commits, SEEN);
724
} while (revs->commits);
725
return NULL;
726
}