Skip to content

Commit

Permalink
Improved overall performance (in particular when opening repositories…
Browse files Browse the repository at this point in the history
…), by only reloading the refs when it's really necessary. This also fixes laullon#188 as the branch badges are correctly calculated on startup.
  • Loading branch information
jphalip committed May 31, 2012
1 parent b57c1b4 commit 21b8f38
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions PBGitRepository.m
Expand Up @@ -186,13 +186,13 @@ - (void) setup
{
config = [[PBGitConfig alloc] initWithRepositoryPath:[[self fileURL] path]];
self.branches = [NSMutableArray array];
[self reloadRefs];
currentBranchFilter = [PBGitDefaults branchFilter];
revisionList = [[PBGitHistoryList alloc] initWithRepository:self];

resetController = [[PBGitResetController alloc] initWithRepository:self];
stashController = [[PBStashController alloc] initWithRepository:self];
submoduleController = [[PBSubmoduleController alloc] initWithRepository:self];
[self reloadRefs];
[self readCurrentBranch];
}

- (void)close
Expand Down
12 changes: 8 additions & 4 deletions PBGitSidebarController.m
Expand Up @@ -84,6 +84,7 @@ - (void)awakeFromNib

[sourceView setDoubleAction:@selector(outlineDoubleClicked)];
[sourceView setTarget:self];
[self updateMetaDataForBranches];
}

- (void)closeView
Expand Down Expand Up @@ -162,15 +163,14 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
for(PBGitSVRemoteItem* remote in [remotes children]){
[self performSelectorInBackground:@selector(evaluateRemoteBadge:) withObject:remote];
}

[self updateMetaDataforBranches:branches];
[self updateMetaDataForBranches];
}else{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}


-(void)updateMetaDataforBranches:(PBSourceViewItem *)theBranches
-(void)updateMetaDataForBranches:(PBSourceViewItem *)theBranches
{
for(PBGitSVBranchItem* branch in [theBranches children]){
if([branch isKindOfClass:[PBGitSVBranchItem class]]){
Expand All @@ -184,11 +184,15 @@ -(void)updateMetaDataforBranches:(PBSourceViewItem *)theBranches
});
});
}else if ([branch isKindOfClass:[PBGitSVFolderItem class]]) {
[self updateMetaDataforBranches: branch];
[self updateMetaDataForBranches: branch];
}
}
}

-(void)updateMetaDataForBranches
{
[self updateMetaDataForBranches: branches];
}

#pragma mark Badges Methods

Expand Down
1 change: 0 additions & 1 deletion PBGitWindowController.m
Expand Up @@ -135,7 +135,6 @@ - (void) changeContentController:(PBViewController *)controller

[self setNextResponder: contentController];
[[self window] makeFirstResponder:[contentController firstResponder]];
[contentController updateView];
[contentController addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionInitial context:@"statusChange"];
}

Expand Down

0 comments on commit 21b8f38

Please sign in to comment.