1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +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++)
{
BOOL found = NO;
NSEnumerator * enumerator = [fGroups objectEnumerator];
NSDictionary * dict;
while ((dict = [enumerator nextObject]))
for (NSDictionary * dict in fGroups)
if ([[dict objectForKey: @"Index"] intValue] == index)
{
found = YES;
@ -333,9 +331,7 @@ GroupsController * fGroupsInstance = nil;
[menu addItem: item];
[item release];
NSEnumerator * enumerator = [fGroups objectEnumerator];
NSMutableDictionary * dict;
while ((dict = [enumerator nextObject]))
for (NSMutableDictionary * dict in fGroups)
{
item = [[NSMenuItem alloc] initWithTitle: [dict objectForKey: @"Name"] action: action keyEquivalent: @""];
[item setTarget: target];
@ -364,9 +360,7 @@ GroupsController * fGroupsInstance = nil;
- (NSInteger) groupIndexForTorrent: (Torrent *) torrent;
{
NSEnumerator * enumerator = [fGroups objectEnumerator];
NSMutableDictionary * group;
while ((group = [enumerator nextObject]))
for (NSDictionary * group in fGroups)
{
NSInteger row = [[group objectForKey: @"Index"] intValue];
if ([self torrent: torrent doesMatchRulesForGroupAtIndex: row])
@ -383,9 +377,7 @@ GroupsController * fGroupsInstance = nil;
{
//don't archive the icon
NSMutableArray * groups = [NSMutableArray arrayWithCapacity: [fGroups count]];
NSEnumerator * enumerator = [fGroups objectEnumerator];
NSDictionary * dict;
while ((dict = [enumerator nextObject]))
for (NSDictionary * dict in fGroups)
{
NSMutableDictionary * tempDict = [dict mutableCopy];
[tempDict removeObjectForKey: @"Icon"];

View file

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

View file

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

View file

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