Skip to content

Commit 69827e9

Browse files
committed
Performance improvements for graphing commits
The big improvement is reusing the PBGraphCellInfo (~8-10%)
1 parent 7c62337 commit 69827e9

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

PBGitCommit.m

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ - (BOOL) isOnHeadBranch
7474

7575
- (BOOL)isEqual:(id)otherCommit
7676
{
77+
if (self == otherCommit)
78+
return YES;
79+
7780
if (![otherCommit isMemberOfClass:[PBGitCommit class]])
7881
return NO;
7982

PBGitGrapher.mm

+10-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ - (void) decorateCommit: (PBGitCommit *) commit
4848

4949
PBGitLane *currentLane = NULL;
5050
BOOL didFirst = NO;
51+
git_oid commit_oid = [[commit sha] oid];
5152

5253
// First, iterate over earlier columns and pass through any that don't want this commit
5354
if (previous != nil) {
@@ -57,7 +58,7 @@ - (void) decorateCommit: (PBGitCommit *) commit
5758
i++;
5859
// This is our commit! We should do a "merge": move the line from
5960
// our upperMapping to their lowerMapping
60-
if ((*it)->isCommit([[commit sha] oid])) {
61+
if ((*it)->isCommit(commit_oid)) {
6162
if (!didFirst) {
6263
didFirst = YES;
6364
currentLanes->push_back(*it);
@@ -127,7 +128,14 @@ - (void) decorateCommit: (PBGitCommit *) commit
127128
add_line(lines, &currentLine, 0, currentLanes->size(), newPos, newLane->index());
128129
}
129130

130-
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
131+
if (commit.lineInfo) {
132+
previous = commit.lineInfo;
133+
previous.position = newPos;
134+
previous.lines = lines;
135+
}
136+
else
137+
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
138+
131139
if (currentLine > maxLines)
132140
NSLog(@"Number of lines: %i vs allocated: %i", currentLine, maxLines);
133141

PBGraphCellInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
char sign;
1919
}
2020

21-
@property(readonly) struct PBGitGraphLine *lines;
21+
@property(assign) struct PBGitGraphLine *lines;
2222
@property(assign) int nLines;
2323
@property(assign) int position, numColumns;
2424
@property(assign) char sign;

0 commit comments

Comments
 (0)