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 :)
This commit is contained in:
Pieter de Bie
2009-01-24 23:54:15 +00:00
parent 4f1fe8a1f6
commit ddc9ae7654
8 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
NSString* details; NSString* details;
NSString *_patch; NSString *_patch;
NSArray* parents; NSArray* parents;
NSMutableArray* refs;
int timestamp; int timestamp;
char sign; char sign;
id lineInfo; id lineInfo;
+14 -4
View File
@@ -11,7 +11,7 @@
@implementation PBGitCommit @implementation PBGitCommit
@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo, refs; @synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
- (NSArray *) parents - (NSArray *) parents
{ {
@@ -107,9 +107,19 @@
if (!self.refs) if (!self.refs)
return; return;
[refs removeObject:ref]; [self.refs removeObject:ref];
if ([refs count] == 0) if ([self.refs count] == 0)
refs = NULL; self.refs = NULL;
}
- (NSMutableArray *)refs
{
return [[repository refs] objectForKey:[self realSha]];
}
- (void) setRefs:(NSMutableArray *)refs
{
[[repository refs] setObject:[self realSha] forKey:[self realSha]];
} }
- (void)finalize - (void)finalize
-2
View File
@@ -15,8 +15,6 @@
PBGraphCellInfo *previous; PBGraphCellInfo *previous;
void *pl; void *pl;
int curLane; int curLane;
NSDictionary *refs;
} }
- (id) initWithRepository:(PBGitRepository *)repo; - (id) initWithRepository:(PBGitRepository *)repo;
-1
View File
@@ -21,7 +21,6 @@ using namespace std;
- (id) initWithRepository: (PBGitRepository*) repo - (id) initWithRepository: (PBGitRepository*) repo
{ {
refs = repo.refs;
pl = new std::list<PBGitLane *>; pl = new std::list<PBGitLane *>;
PBGitLane::resetColors(); PBGitLane::resetColors();
+1 -1
View File
@@ -62,5 +62,5 @@ extern NSString* PBGitRepositoryErrorDomain;
@property (retain) PBGitRevList* revisionList; @property (retain) PBGitRevList* revisionList;
@property (assign) NSMutableArray* branches; @property (assign) NSMutableArray* branches;
@property (assign) PBGitRevSpecifier *currentBranch; @property (assign) PBGitRevSpecifier *currentBranch;
@property (assign) NSMutableDictionary* refs; @property (retain) NSMutableDictionary* refs;
@end @end
-2
View File
@@ -228,8 +228,6 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
[self addRef:newRef fromParameters:components]; [self addRef:newRef fromParameters:components];
} }
self.refs = refs;
// Add an "All branches" option in the branches list // Add an "All branches" option in the branches list
[self addBranch:[PBGitRevSpecifier allBranchesRevSpec]]; [self addBranch:[PBGitRevSpecifier allBranchesRevSpec]];
[self addBranch:[PBGitRevSpecifier localBranchesRevSpec]]; [self addBranch:[PBGitRevSpecifier localBranchesRevSpec]];
+1 -6
View File
@@ -71,7 +71,6 @@ using namespace std;
NSDate *start = [NSDate date]; NSDate *start = [NSDate date];
NSMutableArray* revisions = [NSMutableArray array]; NSMutableArray* revisions = [NSMutableArray array];
PBGitGrapher* g = [[PBGitGrapher alloc] initWithRepository: repository]; PBGitGrapher* g = [[PBGitGrapher alloc] initWithRepository: repository];
NSDictionary* refs = [repository refs];
NSMutableArray* arguments; NSMutableArray* arguments;
BOOL showSign = [rev hasLeftRight]; BOOL showSign = [rev hasLeftRight];
@@ -170,11 +169,7 @@ using namespace std;
[revisions addObject: newCommit]; [revisions addObject: newCommit];
[g decorateCommit: newCommit]; [g decorateCommit: newCommit];
// 0.1 second on linux-2.6
if (refs && [refs objectForKey:[newCommit realSha]])
newCommit.refs = [refs objectForKey:[newCommit realSha]];
if (++num % 1000 == 0) if (++num % 1000 == 0)
[self performSelectorOnMainThread:@selector(setCommits:) withObject:revisions waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(setCommits:) withObject:revisions waitUntilDone:NO];
} }
+1 -1
View File
@@ -2,7 +2,7 @@ var commit;
var Commit = function(obj) { var Commit = function(obj) {
this.object = obj; this.object = obj;
this.refs = obj.refs; this.refs = obj.refs();
this.author_name = obj.author; this.author_name = obj.author;
this.sha = obj.realSha(); this.sha = obj.realSha();
this.parents = obj.parents; this.parents = obj.parents;