Performance improvements for graphing commits

The big improvement is reusing the PBGraphCellInfo (~8-10%)
This commit is contained in:
Nathan Kinsinger
2010-07-03 18:50:09 -06:00
parent 7c62337ab9
commit 69827e920e
3 changed files with 14 additions and 3 deletions
+3
View File
@@ -74,6 +74,9 @@ NSString * const kGitXCommitType = @"commit";
- (BOOL)isEqual:(id)otherCommit
{
if (self == otherCommit)
return YES;
if (![otherCommit isMemberOfClass:[PBGitCommit class]])
return NO;
+10 -2
View File
@@ -48,6 +48,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in
PBGitLane *currentLane = NULL;
BOOL didFirst = NO;
git_oid commit_oid = [[commit sha] oid];
// First, iterate over earlier columns and pass through any that don't want this commit
if (previous != nil) {
@@ -57,7 +58,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in
i++;
// This is our commit! We should do a "merge": move the line from
// our upperMapping to their lowerMapping
if ((*it)->isCommit([[commit sha] oid])) {
if ((*it)->isCommit(commit_oid)) {
if (!didFirst) {
didFirst = YES;
currentLanes->push_back(*it);
@@ -127,7 +128,14 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in
add_line(lines, &currentLine, 0, currentLanes->size(), newPos, newLane->index());
}
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
if (commit.lineInfo) {
previous = commit.lineInfo;
previous.position = newPos;
previous.lines = lines;
}
else
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
if (currentLine > maxLines)
NSLog(@"Number of lines: %i vs allocated: %i", currentLine, maxLines);
+1 -1
View File
@@ -18,7 +18,7 @@
char sign;
}
@property(readonly) struct PBGitGraphLine *lines;
@property(assign) struct PBGitGraphLine *lines;
@property(assign) int nLines;
@property(assign) int position, numColumns;
@property(assign) char sign;