Changeset 7514


Ignore:
Timestamp:
Dec 26, 2008, 7:25:17 AM (12 years ago)
Author:
livings124
Message:

eliminate some more enumerator objects

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/DragOverlayWindow.m

    r7468 r7514  
    8282    NSInteger fileCount = 0;
    8383   
    84     NSString * file;
    85     NSEnumerator * enumerator = [files objectEnumerator];
    86     while ((file = [enumerator nextObject]))
     84    for (NSString * file in files)
    8785    {
    8886        if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
  • trunk/macosx/FileOutlineController.m

    r7508 r7514  
    114114        NSMutableArray * list = [NSMutableArray arrayWithCapacity: [fTorrent fileCount]];
    115115       
    116         NSEnumerator * enumerator = [[fTorrent flatFileList] objectEnumerator];
    117         FileListNode * node;
    118         while ((node = [enumerator nextObject]))
     116        for (FileListNode * node in [fTorrent flatFileList])
    119117            if ([[node name] rangeOfString: fFilterText options: NSCaseInsensitiveSearch].location != NSNotFound)
    120118                [list addObject: node];
  • trunk/macosx/FileOutlineView.m

    r7508 r7514  
    127127    [super updateTrackingAreas];
    128128   
    129     NSEnumerator * enumerator = [[self trackingAreas] objectEnumerator];
    130     NSTrackingArea * area;
    131     while ((area = [enumerator nextObject]))
     129    for (NSTrackingArea * area in [self trackingAreas])
    132130    {
    133131        if ([area owner] == self && [[area userInfo] objectForKey: @"Row"])
  • trunk/macosx/PrefsController.m

    r7508 r7514  
    407407    NSArray * directories = [NSArray arrayWithObjects: @"/System/Library/Sounds", @"/Library/Sounds", @"Library/Sounds", nil];
    408408   
    409     BOOL isDirectory;
    410     NSString * directory;
    411     NSEnumerator * enumerator = [directories objectEnumerator];
    412     while ((directory = [enumerator nextObject]))
     409    for (NSString * directory in directories)
     410    {
     411        BOOL isDirectory;
    413412        if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
    414413        {
    415             NSString * sound;
    416             NSEnumerator * soundEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath: directory] objectEnumerator];
    417             while ((sound = [soundEnumerator nextObject]))
     414            NSArray * directoryContents = [[NSFileManager defaultManager] directoryContentsAtPath: directory];
     415            for (NSString * sound in directoryContents)
    418416            {
    419417                sound = [sound stringByDeletingPathExtension];
     
    422420            }
    423421        }
     422    }
    424423   
    425424    return sounds;
     
    946945    {
    947946        valid = true;
    948         NSEnumerator * enumerator = [components objectEnumerator];
    949         NSString * component;
    950         while ((component = [enumerator nextObject]))
     947        for (NSString * component in components)
    951948        {
    952949            if ([component isEqualToString: @"*"])
     
    11431140        NSToolbar * toolbar = [window toolbar];
    11441141        NSString * itemIdentifier = [toolbar selectedItemIdentifier];
    1145         NSEnumerator * enumerator = [[toolbar items] objectEnumerator];
    1146         NSToolbarItem * item;
    1147         while ((item = [enumerator nextObject]))
     1142        for (NSToolbarItem * item in [toolbar items])
    11481143            if ([[item itemIdentifier] isEqualToString: itemIdentifier])
    11491144            {
  • trunk/macosx/Torrent.m

    r7508 r7514  
    17451745            {
    17461746                //determine if folder node already exists
    1747                 NSEnumerator * enumerator = [fileList objectEnumerator];
    1748                 FileListNode * node;
    1749                 while ((node = [enumerator nextObject]))
     1747                FileListNode * node = nil;
     1748                for (node in fileList)
    17501749                    if ([[node name] isEqualToString: name] && [node isFolder])
    17511750                        break;
     
    17961795    if (isFolder)
    17971796    {
    1798         NSEnumerator * enumerator = [[parent children] objectEnumerator];
    1799         while ((node = [enumerator nextObject]))
     1797        for (node in [parent children])
    18001798            if ([[node name] isEqualToString: name] && [node isFolder])
    18011799                break;
     
    19451943    //get count
    19461944    NSInteger count = 0;
    1947     NSEnumerator * enumerator = [trackers objectEnumerator];
    1948     id object;
    1949     while ((object = [enumerator nextObject]))
     1945    for (id object in trackers)
    19501946        if (![object isKindOfClass: [NSNumber class]])
    19511947            count++;
     
    19541950    tr_tracker_info * trackerStructs = tr_new(tr_tracker_info, count);
    19551951    NSInteger tier = 0, i = 0;
    1956     enumerator = [trackers objectEnumerator];
    1957     while ((object = [enumerator nextObject]))
     1952    for (id object in trackers)
    19581953    {
    19591954        if (![object isKindOfClass: [NSNumber class]])
  • trunk/macosx/TorrentGroup.m

    r7200 r7514  
    5858{
    5959    uint64_t uploaded = 0, downloaded = 0;
    60     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    61     Torrent * torrent;
    62     while ((torrent = [enumerator nextObject]))
     60    for (Torrent * torrent in fTorrents)
    6361    {
    6462        uploaded += [torrent uploadedTotal];
     
    7270{
    7371    CGFloat rate = 0.0f;
    74     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    75     Torrent * torrent;
    76     while ((torrent = [enumerator nextObject]))
     72    for (Torrent * torrent in fTorrents)
    7773        rate += [torrent uploadRate];
    7874   
     
    8379{
    8480    CGFloat rate = 0.0f;
    85     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    86     Torrent * torrent;
    87     while ((torrent = [enumerator nextObject]))
     81    for (Torrent * torrent in fTorrents)
    8882        rate += [torrent downloadRate];
    8983   
Note: See TracChangeset for help on using the changeset viewer.