Skip to content

Commit cd3ebbe

Browse files
committed
Replace some for for() loops with FastEnumeration where i is not needed
Also has the advantage of causing an exception on concurrent modification
1 parent 5239e6d commit cd3ebbe

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Source/SPTableContent.m

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,11 @@ - (void)loadTable:(NSString *)aTable
372372
- (void) setTableDetails:(NSDictionary *)tableDetails
373373
{
374374
NSString *newTableName;
375-
NSInteger i, sortColumnNumberToRestore = NSNotFound;
375+
NSInteger sortColumnNumberToRestore = NSNotFound;
376376
#ifndef SP_CODA
377377
NSNumber *colWidth;
378378
#endif
379379
NSArray *columnNames;
380-
NSDictionary *columnDefinition;
381380
NSMutableDictionary *preservedColumnWidths = nil;
382381
NSTableColumn *theCol;
383382
#ifndef SP_CODA
@@ -566,8 +565,7 @@ - (void) setTableDetails:(NSDictionary *)tableDetails
566565
[tableContentView setRowHeight:2.0f+NSSizeToCGSize([@"{ǞṶḹÜ∑zgyf" sizeWithAttributes:@{NSFontAttributeName : tableFont}]).height];
567566

568567
// Add the new columns to the table and filterTable
569-
for ( i = 0 ; i < (NSInteger)[dataColumns count] ; i++ ) {
570-
columnDefinition = NSArrayObjectAtIndex(dataColumns, i);
568+
for (NSDictionary *columnDefinition in dataColumns ) {
571569

572570
// Set up the column
573571
theCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]];
@@ -1810,18 +1808,15 @@ - (NSString *)argumentForRow:(NSUInteger)rowIndex ofTable:(NSString *)tableForCo
18101808
*/
18111809
- (IBAction)addRow:(id)sender
18121810
{
1813-
NSMutableDictionary *column;
18141811
NSMutableArray *newRow = [NSMutableArray array];
1815-
NSUInteger i;
18161812

18171813
// Check whether table editing is permitted (necessary as some actions - eg table double-click - bypass validation)
18181814
if ([tableDocumentInstance isWorking] || [tablesListInstance tableType] != SPTableTypeTable) return;
18191815

18201816
// Check whether a save of the current row is required.
18211817
if ( ![self saveRowOnDeselect] ) return;
18221818

1823-
for ( i = 0 ; i < [dataColumns count] ; i++ ) {
1824-
column = NSArrayObjectAtIndex(dataColumns, i);
1819+
for (NSDictionary *column in dataColumns) {
18251820
if ([column objectForKey:@"default"] == nil || [[column objectForKey:@"default"] isNSNull]) {
18261821
[newRow addObject:[NSNull null]];
18271822
} else if ([[column objectForKey:@"default"] isEqualToString:@""]
@@ -3146,10 +3141,8 @@ - (NSString *)argumentForRow:(NSInteger)row excludingLimits:(BOOL)excludeLimits
31463141
*/
31473142
- (BOOL)tableContainsBlobOrTextColumns
31483143
{
3149-
NSUInteger i;
3150-
3151-
for ( i = 0 ; i < [dataColumns count]; i++ ) {
3152-
if ( [tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"]] ) {
3144+
for (NSDictionary *column in dataColumns) {
3145+
if ( [tableDataInstance columnIsBlobOrText:[column objectForKey:@"name"]] ) {
31533146
return YES;
31543147
}
31553148
}

0 commit comments

Comments
 (0)