Skip to content

Commit affc0dd

Browse files
committed
Issue #13 - cleaning up ivar storage
Remove @synthesize & use self.
1 parent c6388a9 commit affc0dd

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

Classes/git/PBGitRepository.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,11 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
4343
@class PBGitWindowController;
4444
@class PBGitCommit;
4545
@class PBGitSHA;
46-
@class PBGitRepositoryWatcher;
47-
48-
@interface PBGitRepository : NSDocument {
49-
__strong PBGitRepositoryWatcher *watcher;
50-
__strong PBGitRevSpecifier *_headRef; // Caching
51-
__strong PBGitSHA* _headSha;
52-
__strong GTRepository* _gtRepo;
53-
}
5446

47+
@interface PBGitRepository : NSDocument
5548

56-
@property (assign) BOOL hasChanged;
57-
@property (assign) NSInteger currentBranchFilter;
49+
@property (nonatomic, assign) BOOL hasChanged;
50+
@property (nonatomic, assign) NSInteger currentBranchFilter;
5851

5952
@property (readonly, strong) PBGitWindowController *windowController;
6053
@property (readonly, getter = getIndexURL) NSURL* indexURL;

Classes/git/PBGitRepository.m

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333
@interface PBGitRepository ()
3434

3535
@property (nonatomic, strong) NSNumber *hasSVNRepoConfig;
36+
@property (nonatomic, strong) PBGitRepositoryWatcher *watcher;
37+
@property (nonatomic, strong) PBGitRevSpecifier *headRef; // Caching
38+
@property (nonatomic, strong) PBGitSHA* headSha;
39+
@property (nonatomic, strong) GTRepository* gtRepo;
3640

3741
@end
3842

3943
@implementation PBGitRepository
4044

41-
@synthesize revisionList, branchesSet, currentBranch, refs, hasChanged, submodules;
42-
@synthesize currentBranchFilter;
43-
4445
- (BOOL) isBareRepository
4546
{
4647
return self.gtRepo.isBare;
@@ -105,12 +106,12 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSEr
105106
return NO;
106107
}
107108

108-
revisionList = [[PBGitHistoryList alloc] initWithRepository:self];
109+
self.revisionList = [[PBGitHistoryList alloc] initWithRepository:self];
109110

110111
[self reloadRefs];
111112

112113
// Setup the FSEvents watcher to fire notifications when things change
113-
watcher = [[PBGitRepositoryWatcher alloc] initWithRepository:self];
114+
self.watcher = [[PBGitRepositoryWatcher alloc] initWithRepository:self];
114115

115116
return YES;
116117
}
@@ -127,20 +128,20 @@ - (id) init
127128

128129
self.branchesSet = [NSMutableOrderedSet orderedSet];
129130
self.submodules = [NSMutableArray array];
130-
currentBranchFilter = [PBGitDefaults branchFilter];
131+
self.currentBranchFilter = [PBGitDefaults branchFilter];
131132
return self;
132133
}
133134

134135
- (void)close
135136
{
136-
[revisionList cleanup];
137+
[self.revisionList cleanup];
137138

138139
[super close];
139140
}
140141

141142
- (void) forceUpdateRevisions
142143
{
143-
[revisionList forceUpdate];
144+
[self.revisionList forceUpdate];
144145
}
145146

146147
- (BOOL)isDocumentEdited
@@ -216,10 +217,10 @@ - (void) addRef:(GTReference*)gtRef
216217
PBGitRef* ref = [[PBGitRef alloc] initWithString:gtRef.name];
217218
// NSLog(@"addRef %@ %@ at %@", ref.type, gtRef.name, [sha string]);
218219
NSMutableArray* curRefs;
219-
if ( (curRefs = [refs objectForKey:sha]) != nil )
220+
if ( (curRefs = [self.refs objectForKey:sha]) != nil )
220221
[curRefs addObject:ref];
221222
else
222-
[refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
223+
[self.refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
223224
}
224225

225226
int addSubmoduleName(git_submodule *module, const char* name, void * context)
@@ -249,9 +250,9 @@ - (void) loadSubmodules
249250
- (void) reloadRefs
250251
{
251252
// clear out ref caches
252-
_headRef = nil;
253-
_headSha = nil;
254-
self->refs = [NSMutableDictionary dictionary];
253+
self.headRef = nil;
254+
self.headSha = nil;
255+
self.refs = [NSMutableDictionary dictionary];
255256

256257
NSError* error = nil;
257258
NSArray* allRefs = [self.gtRepo referenceNamesWithError:&error];
@@ -296,11 +297,12 @@ - (void) reloadRefs
296297

297298
- (void) lazyReload
298299
{
299-
if (!hasChanged)
300+
if (!self.hasChanged) {
300301
return;
302+
}
301303

302304
[self.revisionList updateHistory];
303-
hasChanged = NO;
305+
self.hasChanged = NO;
304306
}
305307

306308
- (PBGitRevSpecifier *)headRef
@@ -337,9 +339,9 @@ - (PBGitSHA *)shaForRef:(PBGitRef *)ref
337339
if (!ref)
338340
return nil;
339341

340-
for (PBGitSHA *sha in refs)
342+
for (PBGitSHA *sha in self.refs)
341343
{
342-
for (PBGitRef *existingRef in [refs objectForKey:sha])
344+
for (PBGitRef *existingRef in [self.refs objectForKey:sha])
343345
{
344346
if ([existingRef isEqualToRef:ref])
345347
{
@@ -384,11 +386,11 @@ - (PBGitCommit *)commitForSHA:(PBGitSHA *)sha
384386
{
385387
if (!sha)
386388
return nil;
387-
NSArray *revList = revisionList.projectCommits;
389+
NSArray *revList = self.revisionList.projectCommits;
388390

389391
if (!revList) {
390-
[revisionList forceUpdate];
391-
revList = revisionList.projectCommits;
392+
[self.revisionList forceUpdate];
393+
revList = self.revisionList.projectCommits;
392394
}
393395
for (PBGitCommit *commit in revList)
394396
if ([[commit sha] isEqual:sha])
@@ -405,7 +407,7 @@ - (BOOL)isOnSameBranch:(PBGitSHA *)branchSHA asSHA:(PBGitSHA *)testSHA
405407
if ([testSHA isEqual:branchSHA])
406408
return YES;
407409

408-
NSArray *revList = revisionList.projectCommits;
410+
NSArray *revList = self.revisionList.projectCommits;
409411

410412
NSMutableSet *searchSHAs = [NSMutableSet setWithObject:branchSHA];
411413

@@ -1186,6 +1188,6 @@ - (NSURL*) getIndexURL
11861188
- (void) dealloc
11871189
{
11881190
NSLog(@"Dealloc of repository");
1189-
[watcher stop];
1191+
[self.watcher stop];
11901192
}
11911193
@end

0 commit comments

Comments
 (0)