Optimize revision walker bindings

This simplifies the procedure used to walk revisions
by only loading in commits if the branch selection
was changed.
This commit is contained in:
Pieter de Bie
2008-09-14 15:09:20 +02:00
parent caf3b92e90
commit 8c94e1b514
2 changed files with 9 additions and 6 deletions
+4 -2
View File
@@ -118,8 +118,8 @@ static NSString* gitPath;
if (success) {
[self readRefs];
[self readCurrentBranch];
revisionList = [[PBGitRevList alloc] initWithRepository:self];
[self readCurrentBranch];
}
}
@@ -133,8 +133,10 @@ static NSString* gitPath;
[self setFileURL: gitDirURL];
[self readRefs];
[self selectBranch: [self addBranch: rev]];
revisionList = [[PBGitRevList alloc] initWithRepository:self];
[self selectBranch: [self addBranch: rev]];
return self;
}
// The fileURL the document keeps is to the .git dir, but thats pretty
+5 -4
View File
@@ -18,8 +18,6 @@
- initWithRepository: (id) repo
{
repository = repo;
[self readCommits];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:nil];
return self;
@@ -31,10 +29,13 @@
// we can check if the current branch is the same as the previous one
// and in that case we don't have to reload the revision list.
// If no branch was selected, use the current HEAD
// If no branch is selected, don't do anything
if (![repository currentBranch] || [[repository currentBranch] count] == 0)
return;
NSArray* selectedBranches = [[repository branches] objectsAtIndexes: [repository currentBranch]];
// Apparently, we don't have a current branch yet. Let's skip it.
// Apparently, The selected index does not exist.. don't do anything
if ([selectedBranches count] == 0)
return;