1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

finish fast enumeration conversion

This commit is contained in:
Mitchell Livingston 2008-12-26 15:11:37 +00:00
parent f3add380e5
commit c89caf9cb4
4 changed files with 16 additions and 45 deletions

View file

@ -255,9 +255,7 @@ GroupsController * fGroupsInstance = nil;
for (index = 0; index < [fGroups count]; index++) for (index = 0; index < [fGroups count]; index++)
{ {
BOOL found = NO; BOOL found = NO;
NSEnumerator * enumerator = [fGroups objectEnumerator]; for (NSDictionary * dict in fGroups)
NSDictionary * dict;
while ((dict = [enumerator nextObject]))
if ([[dict objectForKey: @"Index"] intValue] == index) if ([[dict objectForKey: @"Index"] intValue] == index)
{ {
found = YES; found = YES;
@ -333,9 +331,7 @@ GroupsController * fGroupsInstance = nil;
[menu addItem: item]; [menu addItem: item];
[item release]; [item release];
NSEnumerator * enumerator = [fGroups objectEnumerator]; for (NSMutableDictionary * dict in fGroups)
NSMutableDictionary * dict;
while ((dict = [enumerator nextObject]))
{ {
item = [[NSMenuItem alloc] initWithTitle: [dict objectForKey: @"Name"] action: action keyEquivalent: @""]; item = [[NSMenuItem alloc] initWithTitle: [dict objectForKey: @"Name"] action: action keyEquivalent: @""];
[item setTarget: target]; [item setTarget: target];
@ -364,9 +360,7 @@ GroupsController * fGroupsInstance = nil;
- (NSInteger) groupIndexForTorrent: (Torrent *) torrent; - (NSInteger) groupIndexForTorrent: (Torrent *) torrent;
{ {
NSEnumerator * enumerator = [fGroups objectEnumerator]; for (NSDictionary * group in fGroups)
NSMutableDictionary * group;
while ((group = [enumerator nextObject]))
{ {
NSInteger row = [[group objectForKey: @"Index"] intValue]; NSInteger row = [[group objectForKey: @"Index"] intValue];
if ([self torrent: torrent doesMatchRulesForGroupAtIndex: row]) if ([self torrent: torrent doesMatchRulesForGroupAtIndex: row])
@ -383,9 +377,7 @@ GroupsController * fGroupsInstance = nil;
{ {
//don't archive the icon //don't archive the icon
NSMutableArray * groups = [NSMutableArray arrayWithCapacity: [fGroups count]]; NSMutableArray * groups = [NSMutableArray arrayWithCapacity: [fGroups count]];
NSEnumerator * enumerator = [fGroups objectEnumerator]; for (NSDictionary * dict in fGroups)
NSDictionary * dict;
while ((dict = [enumerator nextObject]))
{ {
NSMutableDictionary * tempDict = [dict mutableCopy]; NSMutableDictionary * tempDict = [dict mutableCopy];
[tempDict removeObjectForKey: @"Icon"]; [tempDict removeObjectForKey: @"Icon"];

View file

@ -245,9 +245,7 @@ typedef enum
uint64_t size = 0; uint64_t size = 0;
NSInteger fileCount = 0; NSInteger fileCount = 0;
NSEnumerator * enumerator = [torrents objectEnumerator]; for (Torrent * torrent in torrents)
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{ {
size += [torrent size]; size += [torrent size];
fileCount += [torrent fileCount]; fileCount += [torrent fileCount];
@ -1202,9 +1200,7 @@ typedef enum
return; return;
} }
Torrent * torrent; for (Torrent * torrent in fTorrents)
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
[torrent setSpeedMode: mode upload: upload]; [torrent setSpeedMode: mode upload: upload];
NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField; NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
@ -1226,10 +1222,7 @@ typedef enum
BOOL upload = sender == fUploadLimitField; BOOL upload = sender == fUploadLimitField;
NSInteger limit = [sender intValue]; NSInteger limit = [sender intValue];
Torrent * torrent; for (Torrent * torrent in fTorrents)
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
[torrent setSpeedLimit: limit upload: upload]; [torrent setSpeedLimit: limit upload: upload];
} }
@ -1251,9 +1244,7 @@ typedef enum
return; return;
} }
Torrent * torrent; for (Torrent * torrent in fTorrents)
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
[torrent setRatioSetting: setting]; [torrent setRatioSetting: setting];
BOOL single = setting == NSOnState; BOOL single = setting == NSOnState;
@ -1271,9 +1262,7 @@ typedef enum
{ {
CGFloat limit = [sender floatValue]; CGFloat limit = [sender floatValue];
Torrent * torrent; for (Torrent * torrent in fTorrents)
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
[torrent setRatioLimit: limit]; [torrent setRatioLimit: limit];
} }
@ -1281,9 +1270,7 @@ typedef enum
{ {
NSInteger limit = [sender intValue]; NSInteger limit = [sender intValue];
Torrent * torrent; for (Torrent * torrent in fTorrents)
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
[torrent setMaxPeerConnect: limit]; [torrent setMaxPeerConnect: limit];
} }
@ -1334,9 +1321,7 @@ typedef enum
uint64_t have = 0, haveVerified = 0, downloadedTotal = 0, uploadedTotal = 0, failedHash = 0; uint64_t have = 0, haveVerified = 0, downloadedTotal = 0, uploadedTotal = 0, failedHash = 0;
NSDate * lastActivity = nil; NSDate * lastActivity = nil;
Torrent * torrent; for (Torrent * torrent in fTorrents)
NSEnumerator * enumerator = [fTorrents objectEnumerator];
while ((torrent = [enumerator nextObject]))
{ {
have += [torrent haveTotal]; have += [torrent haveTotal];
haveVerified += [torrent haveVerified]; haveVerified += [torrent haveVerified];
@ -1369,7 +1354,7 @@ typedef enum
if (numberSelected == 1) if (numberSelected == 1)
{ {
torrent = [fTorrents objectAtIndex: 0]; Torrent * torrent = [fTorrents objectAtIndex: 0];
[fStateField setStringValue: [torrent stateString]]; [fStateField setStringValue: [torrent stateString]];

View file

@ -1744,7 +1744,7 @@ int trashDataFile(const char * filename)
if ([pathComponents count] > 0) if ([pathComponents count] > 0)
{ {
//determine if folder node already exists //determine if folder node already exists
FileListNode * node = nil; FileListNode * node;
for (node in fileList) for (node in fileList)
if ([[node name] isEqualToString: name] && [node isFolder]) if ([[node name] isEqualToString: name] && [node isFolder])
break; break;

View file

@ -245,9 +245,7 @@
fMouseRevealRow = -1; fMouseRevealRow = -1;
fMouseActionRow = -1; fMouseActionRow = -1;
NSEnumerator * enumerator = [[self trackingAreas] objectEnumerator]; for (NSTrackingArea * area in [self trackingAreas])
NSTrackingArea * area;
while ((area = [enumerator nextObject]))
{ {
if ([area owner] == self && [[area userInfo] objectForKey: @"Row"]) if ([area owner] == self && [[area userInfo] objectForKey: @"Row"])
[self removeTrackingArea: area]; [self removeTrackingArea: area];
@ -402,9 +400,7 @@
{ {
NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSet]; NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSet];
NSEnumerator * enumerator = [values objectEnumerator]; for (id item in values)
id item;
while ((item = [enumerator nextObject]))
{ {
if ([item isKindOfClass: [Torrent class]]) if ([item isKindOfClass: [Torrent class]])
{ {
@ -881,9 +877,7 @@
- (void) createFileMenu: (NSMenu *) menu forFiles: (NSArray *) files - (void) createFileMenu: (NSMenu *) menu forFiles: (NSArray *) files
{ {
NSEnumerator * enumerator = [files objectEnumerator]; for (FileListNode * node in files)
FileListNode * node;
while ((node = [enumerator nextObject]))
{ {
NSString * name = [node name]; NSString * name = [node name];