Changeset 449


Ignore:
Timestamp:
Jun 23, 2006, 5:46:53 PM (17 years ago)
Author:
livings124
Message:

A little bit more thorough check to avoid excess work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r448 r449  
    10141014            {
    10151015                if (![torrent isSeeding])
     1016                {
    10161017                    amountToStart--;
     1018                    if (amountToStart <= 0)
     1019                        break;
     1020                }
    10171021            }
    10181022            else if ([torrent waitingToStart])
     
    10221026       
    10231027        int waitingCount = [waitingTorrents count];
    1024         if (amountToStart > waitingCount)
    1025             amountToStart = waitingCount;
    1026        
    1027         //sort torrents by date to start earliest added
    1028         if (amountToStart > 0 && amountToStart < waitingCount)
    1029         {
    1030             NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
    1031                                                         @"date" ascending: YES] autorelease];
    1032             NSArray * descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, nil];
     1028       
     1029        if (amountToStart > 0 && waitingCount > 0)
     1030        {
     1031            if (amountToStart > waitingCount)
     1032                amountToStart = waitingCount;
    10331033           
    1034             [waitingTorrents sortUsingDescriptors: descriptors];
    1035             [descriptors release];
    1036         }
    1037        
    1038         int i;
    1039         for (i = 0; i < amountToStart; i++)
    1040             [[waitingTorrents objectAtIndex: i] startTransfer];
     1034            //sort torrents by date to start earliest added
     1035            if (amountToStart < waitingCount)
     1036            {
     1037                NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
     1038                                                            @"date" ascending: YES] autorelease];
     1039                NSArray * descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, nil];
     1040               
     1041                [waitingTorrents sortUsingDescriptors: descriptors];
     1042                [descriptors release];
     1043            }
     1044           
     1045            int i;
     1046            for (i = 0; i < amountToStart; i++)
     1047                [[waitingTorrents objectAtIndex: i] startTransfer];
     1048        }
    10411049       
    10421050        [waitingTorrents release];
Note: See TracChangeset for help on using the changeset viewer.