Browse files

Performance improvements for graphing commits

The big improvement is reusing the PBGraphCellInfo (~8-10%)
  • Loading branch information...
1 parent 7c62337 commit 69827e920e904cd8634367bcb022d6ba837b4dda @brotherbard committed Jul 4, 2010
Showing with 14 additions and 3 deletions.
  1. +3 −0 PBGitCommit.m
  2. +10 −2 PBGitGrapher.mm
  3. +1 −1 PBGraphCellInfo.h
View
3 PBGitCommit.m
@@ -74,6 +74,9 @@ - (BOOL) isOnHeadBranch
- (BOOL)isEqual:(id)otherCommit
{
+ if (self == otherCommit)
+ return YES;
+
if (![otherCommit isMemberOfClass:[PBGitCommit class]])
return NO;
View
12 PBGitGrapher.mm
@@ -48,6 +48,7 @@ - (void) decorateCommit: (PBGitCommit *) commit
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) decorateCommit: (PBGitCommit *) commit
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) decorateCommit: (PBGitCommit *) commit
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);
View
2 PBGraphCellInfo.h
@@ -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;

0 comments on commit 69827e9

Please sign in to comment.