From bb5696c704a2770aff0dc2b947d40af4645aed1b Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Thu, 20 Nov 2008 15:58:52 +0100 Subject: [PATCH] GitGrapher: Limit the maximum number of lanes This limits the maximum number of lanes to 32, making the graphing a lot faster. For example, linux-2.6.git takes only 30 seconds now, rather than >400 --- PBGitGrapher.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PBGitGrapher.m b/PBGitGrapher.m index f3af7ae..299e8d4 100644 --- a/PBGitGrapher.m +++ b/PBGitGrapher.m @@ -12,11 +12,13 @@ @implementation PBGitGrapher +#define MAX_LANES 32 + - (id) initWithRepository: (PBGitRepository*) repo { refs = repo.refs; repository = repo; - previousLanes = [NSMutableArray array]; + previousLanes = [NSMutableArray arrayWithCapacity:MAX_LANES]; [PBGitLane resetColors]; return self; @@ -25,7 +27,7 @@ - (void) decorateCommit: (PBGitCommit *) commit { int i = 0, newPos = -1; - NSMutableArray* currentLanes = [NSMutableArray array]; + NSMutableArray* currentLanes = [NSMutableArray arrayWithCapacity:MAX_LANES]; NSMutableArray* lines = [NSMutableArray array]; PBGitLane* currentLane = NULL; BOOL didFirst = NO; @@ -82,7 +84,7 @@ //Add your own parents // If we already did the first parent, don't do so again - if (!didFirst) { + if (!didFirst && [currentLanes count] < MAX_LANES) { PBGitLane* newLane = [[PBGitLane alloc] initWithCommit:[commit.parents objectAtIndex:0]]; [currentLanes addObject: newLane]; newPos = [currentLanes count]; @@ -109,6 +111,9 @@ if (was_displayed) continue; + if ([currentLanes count] >= MAX_LANES) + break; + // Really add this parent addedParent = YES; PBGitLane* newLane = [[PBGitLane alloc] initWithCommit:parent];