Skip to content

Commit 9571382

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

8 files changed

+62
-64
lines changed

Classes/git/PBGitRepositoryWatcher.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
//
1010

1111
#import <Foundation/Foundation.h>
12-
#import "PBGitRepository.h"
12+
13+
@class PBGitRepository;
1314

1415
typedef UInt32 PBGitRepositoryWatcherEventType;
1516
enum {
@@ -32,8 +33,6 @@ extern NSString *kPBGitRepositoryEventPathsUserInfoKey;
3233
NSDictionary* lastStatus;
3334
}
3435

35-
@property (readonly, weak) PBGitRepository *repository;
36-
3736
- (id) initWithRepository:(PBGitRepository *)repository;
3837
- (void) start;
3938
- (void) stop;

Classes/git/PBGitRepositoryWatcher.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// Copyright 2009 __MyCompanyName__. All rights reserved.
77
//
88
#import <CoreServices/CoreServices.h>
9+
910
#import "PBGitRepositoryWatcher.h"
11+
12+
#import "PBGitRepository.h"
1013
#import "PBEasyPipe.h"
1114
#import "PBGitDefaults.h"
1215
#import "PBGitRepositoryWatcherEventPath.h"
@@ -18,6 +21,9 @@
1821
NSString *kPBGitRepositoryEventPathsUserInfoKey = @"kPBGitRepositoryEventPathsUserInfoKey";
1922

2023
@interface PBGitRepositoryWatcher ()
24+
25+
@property (readonly, weak) PBGitRepository *repository;
26+
2127
- (void) _handleEventCallback:(NSArray *)eventPaths;
2228
@end
2329

Classes/git/PBGitRepositoryWatcherEventPath.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111

1212
@interface PBGitRepositoryWatcherEventPath : NSObject
13-
{
14-
NSString *path;
15-
FSEventStreamEventFlags flag;
16-
}
1713

18-
@property NSString *path;
19-
@property (assign) FSEventStreamEventFlags flag;
14+
@property (nonatomic, assign) FSEventStreamEventFlags flag;
15+
@property (nonatomic, strong) NSString * path;
16+
2017
@end

Classes/git/PBGitRepositoryWatcherEventPath.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111

1212
@implementation PBGitRepositoryWatcherEventPath
13-
@synthesize path, flag;
1413

1514
@end

Classes/git/PBGitRevList.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@
1212
@class PBGitRevSpecifier;
1313

1414
@interface PBGitRevList : NSObject {
15-
NSMutableArray *commits;
16-
1715
__weak PBGitRepository *repository;
1816
PBGitRevSpecifier *currentRev;
1917
BOOL isGraphing;
2018

2119
NSThread *parseThread;
22-
BOOL isParsing;
2320
BOOL resetCommits;
2421
}
2522

2623
- (id) initWithRepository:(PBGitRepository *)repo rev:(PBGitRevSpecifier *)rev shouldGraph:(BOOL)graph;
2724
- (void) loadRevisons;
2825
- (void)cancel;
2926

30-
@property NSMutableArray *commits;
31-
@property (readonly) BOOL isParsing;
27+
@property (nonatomic, assign, readonly) BOOL isParsing;
28+
@property (nonatomic, readonly) NSArray *commits;
3229

3330
@end

Classes/git/PBGitRevList.mm

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
@interface PBGitRevList ()
2626

27-
@property (assign) BOOL isParsing;
27+
@property (nonatomic, strong) NSMutableArray *commitsRW;
28+
@property (nonatomic, assign) BOOL isParsing;
2829

2930
@end
3031

@@ -35,9 +36,6 @@ @interface PBGitRevList ()
3536

3637
@implementation PBGitRevList
3738

38-
@synthesize commits;
39-
@synthesize isParsing;
40-
4139

4240
- (id) initWithRepository:(PBGitRepository *)repo rev:(PBGitRevSpecifier *)rev shouldGraph:(BOOL)graph
4341
{
@@ -59,6 +57,10 @@ - (void) loadRevisons
5957
[parseThread start];
6058
}
6159

60+
- (NSArray*)commits
61+
{
62+
return self.commitsRW;
63+
}
6264

6365
- (void)cancel
6466
{
@@ -82,23 +84,23 @@ - (void) updateCommits:(NSDictionary *)update
8284
return;
8385

8486
if (resetCommits) {
85-
self.commits = [NSMutableArray array];
87+
self.commitsRW = [NSMutableArray array];
8688
resetCommits = NO;
8789
}
8890

89-
NSRange range = NSMakeRange([commits count], [revisions count]);
91+
NSRange range = NSMakeRange([self.commitsRW count], [revisions count]);
9092
NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange:range];
9193

9294
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes forKey:@"commits"];
93-
[commits addObjectsFromArray:revisions];
95+
[self.commitsRW addObjectsFromArray:revisions];
9496
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes forKey:@"commits"];
9597
}
9698

9799

98100
- (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
99101
{
100102
@autoreleasepool {
101-
NSDate *start = [NSDate date];
103+
//NSDate *start = [NSDate date];
102104
NSDate *lastUpdate = [NSDate date];
103105
NSMutableArray *revisions = [NSMutableArray array];
104106
PBGitGrapher *g = [[PBGitGrapher alloc] initWithRepository:repository];
@@ -267,7 +269,7 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
267269
}
268270

269271
if (![currentThread isCancelled]) {
270-
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start];
272+
//NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start];
271273
//NSLog(@"Loaded %i commits in %f seconds (%f/sec)", num, duration, num/duration);
272274

273275
// Make sure the commits are stored before exiting.

Classes/git/PBGitRevSpecifier.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
#import <Cocoa/Cocoa.h>
1010
#import "PBGitRef.h"
1111

12-
@interface PBGitRevSpecifier : NSObject <NSCopying> {
13-
NSString *description;
14-
NSArray *parameters;
15-
NSURL *workingDirectory;
16-
BOOL isSimpleRef;
17-
}
12+
@interface PBGitRevSpecifier : NSObject <NSCopying>
1813

1914
- (id) initWithParameters:(NSArray *)params description:(NSString *)descrip;
2015
- (id) initWithParameters:(NSArray*) params;
@@ -33,9 +28,10 @@
3328
+ (PBGitRevSpecifier *)allBranchesRevSpec;
3429
+ (PBGitRevSpecifier *)localBranchesRevSpec;
3530

36-
@property(retain) NSString *description;
37-
@property(readonly) NSArray *parameters;
38-
@property(retain) NSURL *workingDirectory;
39-
@property(readonly) BOOL isSimpleRef;
31+
@property(nonatomic, strong, readonly) NSString *description;
32+
@property(nonatomic, strong, readonly) NSArray *parameters;
33+
@property(nonatomic, assign, readonly) BOOL isSimpleRef;
34+
35+
@property(nonatomic, strong) NSURL *workingDirectory;
4036

4137
@end

Classes/git/PBGitRevSpecifier.m

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,56 @@
88

99
#import "PBGitRevSpecifier.h"
1010

11+
@interface PBGitRevSpecifier ()
1112

12-
@implementation PBGitRevSpecifier
13+
@property(nonatomic, strong) NSString *description;
14+
@property(nonatomic, strong) NSArray *parameters;
15+
@property(nonatomic, assign) BOOL isSimpleRef;
1316

14-
@synthesize parameters, description, workingDirectory;
15-
@synthesize isSimpleRef;
17+
@end
1618

19+
@implementation PBGitRevSpecifier
1720

1821
// internal designated init
1922
- (id) initWithParameters:(NSArray *)params description:(NSString *)descrip
2023
{
2124
self = [super init];
22-
parameters = params;
23-
description = descrip;
25+
if (!self) {
26+
return nil;
27+
}
28+
29+
self.parameters = params;
30+
self.description = descrip;
2431

25-
if (([parameters count] > 1) || ([parameters count] == 0))
26-
isSimpleRef = NO;
32+
if (([self.parameters count] > 1) || ([self.parameters count] == 0))
33+
self.isSimpleRef = NO;
2734
else {
28-
NSString *param = [parameters objectAtIndex:0];
35+
NSString *param = [self.parameters objectAtIndex:0];
2936
if ([param hasPrefix:@"-"] ||
3037
[param rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"^@{}~:"]].location != NSNotFound ||
3138
[param rangeOfString:@".."].location != NSNotFound)
32-
isSimpleRef = NO;
39+
self.isSimpleRef = NO;
3340
else
34-
isSimpleRef = YES;
41+
self.isSimpleRef = YES;
3542
}
3643

3744
return self;
3845
}
3946

4047
- (id) initWithParameters:(NSArray *)params
4148
{
42-
self = [super init];
4349
self = [self initWithParameters:params description:nil];
4450
return self;
4551
}
4652

4753
- (id) initWithRef:(PBGitRef *)ref
4854
{
49-
self = [super init];
5055
self = [self initWithParameters:[NSArray arrayWithObject:ref.ref] description:ref.shortName];
5156
return self;
5257
}
5358

5459
- (id) initWithCoder:(NSCoder *)coder
5560
{
56-
self = [super init];
5761
self = [self initWithParameters:[coder decodeObjectForKey:@"Parameters"] description:[coder decodeObjectForKey:@"Description"]];
5862
return self;
5963
}
@@ -73,7 +77,7 @@ - (NSString*) simpleRef
7377
{
7478
if (![self isSimpleRef])
7579
return nil;
76-
return [parameters objectAtIndex:0];
80+
return [self.parameters objectAtIndex:0];
7781
}
7882

7983
- (PBGitRef *) ref
@@ -86,18 +90,12 @@ - (PBGitRef *) ref
8690

8791
- (NSString *) description
8892
{
89-
if (!description)
90-
return [parameters componentsJoinedByString:@" "];
91-
92-
return description;
93-
}
94-
95-
- (void) setDescription:(NSString *)newDescription
96-
{
97-
description = newDescription;
93+
if (!self->_description) {
94+
return [self.parameters componentsJoinedByString:@" "];
95+
}
96+
return self->_description;
9897
}
9998

100-
10199
- (NSString *) title
102100
{
103101
NSString *title = nil;
@@ -122,17 +120,21 @@ - (NSString *) title
122120

123121
- (BOOL) hasPathLimiter;
124122
{
125-
for (NSString* param in parameters)
126-
if ([param isEqualToString:@"--"])
123+
for (NSString* param in self.parameters) {
124+
if ([param isEqualToString:@"--"]) {
127125
return YES;
126+
}
127+
}
128128
return NO;
129129
}
130130

131131
- (BOOL) hasLeftRight
132132
{
133-
for (NSString* param in parameters)
134-
if ([param isEqualToString:@"--left-right"])
133+
for (NSString* param in self.parameters) {
134+
if ([param isEqualToString:@"--left-right"]) {
135135
return YES;
136+
}
137+
}
136138
return NO;
137139
}
138140

@@ -167,8 +169,8 @@ - (BOOL) isLocalBranchesRev
167169

168170
- (void) encodeWithCoder:(NSCoder *)coder
169171
{
170-
[coder encodeObject:description forKey:@"Description"];
171-
[coder encodeObject:parameters forKey:@"Parameters"];
172+
[coder encodeObject:self.description forKey:@"Description"];
173+
[coder encodeObject:self.parameters forKey:@"Parameters"];
172174
}
173175

174176
- (id)copyWithZone:(NSZone *)zone

0 commit comments

Comments
 (0)