Skip to content

Commit ddc9ae7

Browse files
committed
PBGitCommit: Don't store refs
We already keep this dictionary in our repository. Rather than adding a pointer to it on every commit in our rev walk, just look it up lazily in the dictionary when we need to. That cuts down some time in the initial revwalk and also removes some stupid code :)
1 parent 4f1fe8a commit ddc9ae7

8 files changed

+18
-18
lines changed

PBGitCommit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
NSString* details;
2222
NSString *_patch;
2323
NSArray* parents;
24-
NSMutableArray* refs;
24+
2525
int timestamp;
2626
char sign;
2727
id lineInfo;

PBGitCommit.m

+14-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@implementation PBGitCommit
1313

14-
@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo, refs;
14+
@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
1515

1616
- (NSArray *) parents
1717
{
@@ -107,9 +107,19 @@ - (void)removeRef:(id)ref
107107
if (!self.refs)
108108
return;
109109

110-
[refs removeObject:ref];
111-
if ([refs count] == 0)
112-
refs = NULL;
110+
[self.refs removeObject:ref];
111+
if ([self.refs count] == 0)
112+
self.refs = NULL;
113+
}
114+
115+
- (NSMutableArray *)refs
116+
{
117+
return [[repository refs] objectForKey:[self realSha]];
118+
}
119+
120+
- (void) setRefs:(NSMutableArray *)refs
121+
{
122+
[[repository refs] setObject:[self realSha] forKey:[self realSha]];
113123
}
114124

115125
- (void)finalize

PBGitGrapher.h

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
PBGraphCellInfo *previous;
1616
void *pl;
1717
int curLane;
18-
19-
NSDictionary *refs;
2018
}
2119

2220
- (id) initWithRepository:(PBGitRepository *)repo;

PBGitGrapher.mm

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ @implementation PBGitGrapher
2121

2222
- (id) initWithRepository: (PBGitRepository*) repo
2323
{
24-
refs = repo.refs;
2524
pl = new std::list<PBGitLane *>;
2625

2726
PBGitLane::resetColors();

PBGitRepository.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ extern NSString* PBGitRepositoryErrorDomain;
6262
@property (retain) PBGitRevList* revisionList;
6363
@property (assign) NSMutableArray* branches;
6464
@property (assign) PBGitRevSpecifier *currentBranch;
65-
@property (assign) NSMutableDictionary* refs;
65+
@property (retain) NSMutableDictionary* refs;
6666
@end

PBGitRepository.m

-2
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ - (BOOL) reloadRefs
228228
[self addRef:newRef fromParameters:components];
229229
}
230230

231-
self.refs = refs;
232-
233231
// Add an "All branches" option in the branches list
234232
[self addBranch:[PBGitRevSpecifier allBranchesRevSpec]];
235233
[self addBranch:[PBGitRevSpecifier localBranchesRevSpec]];

PBGitRevList.mm

+1-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
7171
NSDate *start = [NSDate date];
7272
NSMutableArray* revisions = [NSMutableArray array];
7373
PBGitGrapher* g = [[PBGitGrapher alloc] initWithRepository: repository];
74-
NSDictionary* refs = [repository refs];
7574

7675
NSMutableArray* arguments;
7776
BOOL showSign = [rev hasLeftRight];
@@ -170,11 +169,7 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
170169

171170
[revisions addObject: newCommit];
172171
[g decorateCommit: newCommit];
173-
174-
// 0.1 second on linux-2.6
175-
if (refs && [refs objectForKey:[newCommit realSha]])
176-
newCommit.refs = [refs objectForKey:[newCommit realSha]];
177-
172+
178173
if (++num % 1000 == 0)
179174
[self performSelectorOnMainThread:@selector(setCommits:) withObject:revisions waitUntilDone:NO];
180175
}

html/views/history/history.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var commit;
22
var Commit = function(obj) {
33
this.object = obj;
44

5-
this.refs = obj.refs;
5+
this.refs = obj.refs();
66
this.author_name = obj.author;
77
this.sha = obj.realSha();
88
this.parents = obj.parents;

0 commit comments

Comments
 (0)