Skip to content

Commit

Permalink
show-branch: Fix another performance problem.
Browse files Browse the repository at this point in the history
When naming commits, stop walking the parent chain as soon as we find
a commit that already has a name. The parent chain of that commit will
be walked later on in any case (or may even have been walked already).
This avoids O(n^2) behavior; on a tree where show-branch displays 6800
commits, the total run time drops from 77 seconds to 5 seconds.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Alexandre Julliard authored and Junio C Hamano committed Jul 24, 2006
1 parent 4812a93 commit f8263c5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builtin-show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ static int name_first_parent_chain(struct commit *c)
name_parent(c, p);
i++;
}
else
break;
c = p;
}
return i;
Expand Down

0 comments on commit f8263c5

Please sign in to comment.