# [PATCH] show-branch: Fix another performance problem.

2 messages from 2006-07-23 to 2006-07-24. Participants: Alexandre Julliard, Junio C Hamano.
Thread: https://gitlist.dev/t/4958

## Alexandre Julliard, 2006-07-23 17:51

Subject: [PATCH] show-branch: Fix another performance problem.
Message-ID: <87mzb0fbw7.fsf@wine.dyndns.org>
URL: https://gitlist.dev/e/87mzb0fbw7.fsf%40wine.dyndns.org

```
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>
---
 builtin-show-branch.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 3d240ca..82f75b7 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -89,6 +89,8 @@ static int name_first_parent_chain(struc
 			name_parent(c, p);
 			i++;
 		}
+		else
+			break;
 		c = p;
 	}
 	return i;
-- 
1.4.2.rc1.ge7a0

-- 
Alexandre Julliard
julliard@winehq.org

```

## Junio C Hamano, 2006-07-24 06:46

Subject: Re: [PATCH] show-branch: Fix another performance problem.
Message-ID: <7v64hnfqjk.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v64hnfqjk.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <87mzb0fbw7.fsf@wine.dyndns.org>

```
Thanks.

```
