Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

don't need retain/release IMPs; pass tableview to object-attribute ca…

…llbacks for state-checking
  • Loading branch information...
commit 151f9df9939b2d977740f6283ab8ec759be521be 1 parent f175bce
Zachary Schneirov authored

Showing 2 changed files with 4 additions and 22 deletions. Show diff stats Hide diff stats

  1. +0 3  FastListDataSource.h
  2. +4 19 FastListDataSource.m
3  FastListDataSource.h
@@ -8,14 +8,11 @@
8 8
9 9 #import <Cocoa/Cocoa.h>
10 10
11   -
12 11 @interface FastListDataSource : NSObject {
13 12 id *objects;
14 13 NSUInteger count;
15   - IMP objRetain, objRelease;
16 14 }
17 15
18   -- (id)initWithClass:(Class)aClass;
19 16 - (const id *)immutableObjects;
20 17 - (NSUInteger)count;
21 18
23 FastListDataSource.m
@@ -7,26 +7,11 @@
7 7 //
8 8
9 9 #import "FastListDataSource.h"
  10 +#import "NotesTableView.h"
10 11 #import "NoteAttributeColumn.h"
11 12
12 13 @implementation FastListDataSource
13 14
14   -- (id)initWithClass:(Class)aClass {
15   - if ([super init]) {
16   - objects = NULL;
17   - count = 0;
18   -
19   - if (![aClass instancesRespondToSelector:@selector(retain)] ||
20   - ![aClass instancesRespondToSelector:@selector(release)])
21   - return nil;
22   -
23   - objRetain = [aClass instanceMethodForSelector:@selector(retain)];
24   - objRelease = [aClass instanceMethodForSelector:@selector(release)];
25   - }
26   -
27   - return self;
28   -}
29   -
30 15 - (const id *)immutableObjects {
31 16 return (const id *)objects;
32 17 }
@@ -59,7 +44,7 @@ - (NSArray*)objectsAtFilteredIndexes:(NSIndexSet*)indexSet {
59 44 NSRange range = NSMakeRange([indexSet firstIndex],
60 45 [indexSet lastIndex]-[indexSet firstIndex]+1);
61 46
62   - NSMutableArray *objectsInIndexSet = [[NSMutableArray alloc] init];
  47 + NSMutableArray *objectsInIndexSet = [[NSMutableArray alloc] initWithCapacity:[indexSet count]];
63 48
64 49 while ((indexCount = [indexSet getIndexes:indexBuffer maxCount:40 inIndexRange:&range])) {
65 50
@@ -75,7 +60,6 @@ - (NSArray*)objectsAtFilteredIndexes:(NSIndexSet*)indexSet {
75 60 return [objectsInIndexSet autorelease];
76 61 }
77 62
78   -
79 63 //as long as this class is only used for temporary display, we probably do not need to uncomment the retains and releases
80 64
81 65 - (void)fillArrayFromArray:(NSArray*)array {
@@ -135,7 +119,8 @@ - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
135 119
136 120
137 121 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
138   - return columnAttributeForObject((NoteAttributeColumn*)aTableColumn, objects[rowIndex]);
  122 +
  123 + return columnAttributeForObject((NotesTableView*)aTableView, (NoteAttributeColumn*)aTableColumn, objects[rowIndex]);
139 124 }
140 125
141 126 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {

0 comments on commit 151f9df

Please sign in to comment.
Something went wrong with that request. Please try again.