From 21b8f38b7cdf54489a4514a8001c44bcfcedef6a Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Tue, 29 May 2012 19:47:42 -0700 Subject: [PATCH] Improved overall performance (in particular when opening repositories), by only reloading the refs when it's really necessary. This also fixes #188 as the branch badges are correctly calculated on startup. --- PBGitRepository.m | 4 ++-- PBGitSidebarController.m | 12 ++++++++---- PBGitWindowController.m | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/PBGitRepository.m b/PBGitRepository.m index d6d5027c7..075ae864d 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -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 diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index 1b423fd7b..276f35157 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -84,6 +84,7 @@ - (void)awakeFromNib [sourceView setDoubleAction:@selector(outlineDoubleClicked)]; [sourceView setTarget:self]; + [self updateMetaDataForBranches]; } - (void)closeView @@ -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]]){ @@ -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 diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 51ad6af1f..2730f0190 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -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"]; }