Changeset 3944


Ignore:
Timestamp:
Nov 23, 2007, 3:45:58 PM (14 years ago)
Author:
livings124
Message:

get rid of unneeded sort descriptors; hold queue order as an integer instead of an object

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r3934 r3944  
    11451145        [torrent setWaitToStart: NO];
    11461146
    1147     NSNumber * lowestOrderValue = nil, * currentOrderValue;
     1147    int lowestOrderValue = -1, currentOrderValue;
    11481148
    11491149    enumerator = [torrents objectEnumerator];
     
    11591159        //determine lowest order value
    11601160        currentOrderValue = [torrent orderValue];
    1161         if (!lowestOrderValue || [lowestOrderValue compare: currentOrderValue] == NSOrderedDescending)
     1161        if (lowestOrderValue < currentOrderValue)
    11621162            lowestOrderValue = currentOrderValue;
    11631163       
     
    11691169
    11701170    //reset the order values if necessary
    1171     if ([lowestOrderValue intValue] < [fTorrents count])
     1171    if (lowestOrderValue < [fTorrents count])
    11721172    {
    11731173        NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
     
    11791179
    11801180        int i;
    1181         for (i = [lowestOrderValue intValue]; i < [tempTorrents count]; i++)
     1181        for (i = lowestOrderValue; i < [tempTorrents count]; i++)
    11821182            [[tempTorrents objectAtIndex: i] setOrderValue: i];
    11831183    }
     
    16031603                                                @"stateSortKey" ascending: !asc] autorelease],
    16041604                        * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
    1605                                             @"progressSortKey" ascending: !asc] autorelease],
     1605                                            @"progress" ascending: !asc] autorelease],
    16061606                        * ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
    16071607                                            @"ratioSortKey" ascending: !asc] autorelease];
     
    16131613    {
    16141614        NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
    1615                                             @"progressSortKey" ascending: asc] autorelease],
     1615                                            @"progress" ascending: asc] autorelease],
    16161616                        * ratioProgressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
    16171617                                            @"ratioProgressSortKey" ascending: asc] autorelease],
     
    21902190       
    21912191        //reinsert into array
    2192         int insertIndex = newRow > 0 ? [[[fDisplayedTorrents objectAtIndex: newRow-1] orderValue] intValue] + 1 : 0;
     2192        int insertIndex = newRow > 0 ? [[fDisplayedTorrents objectAtIndex: newRow-1] orderValue] + 1 : 0;
    21932193       
    21942194        //get all torrents to reorder
  • trunk/macosx/Torrent.h

    r3934 r3944  
    6262    NSMenu * fFileMenu;
    6363   
    64     float   fRatioLimit;
    65     int     fRatioSetting;
    66     BOOL    fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
    67    
    68     NSNumber * fOrderValue;
     64    float fRatioLimit;
     65    int fRatioSetting;
     66    BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
     67   
     68    int fOrderValue;
    6969   
    7070    NSDictionary * fQuickPauseDict;
     
    202202- (void) setPex: (BOOL) enable;
    203203
    204 - (NSNumber *) orderValue;
     204- (int) orderValue;
    205205- (void) setOrderValue: (int) orderValue;
    206206
     
    230230
    231231- (NSNumber *) stateSortKey;
    232 - (NSNumber *) progressSortKey;
    233232- (NSNumber *) ratioSortKey;
    234233- (NSNumber *) ratioProgressSortKey;
  • trunk/macosx/Torrent.m

    r3934 r3944  
    126126                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
    127127                    [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
    128                     [self orderValue], @"OrderValue", nil];
     128                    [NSNumber numberWithInt: fOrderValue], @"OrderValue", nil];
    129129   
    130130    if (fIncompleteFolder)
     
    162162    [fFileList release];
    163163    [fFileMenu release];
    164    
    165     [fOrderValue release];
    166164   
    167165    [fQuickPauseDict release];
     
    11521150}
    11531151
    1154 - (NSNumber *) orderValue
     1152- (int) orderValue
    11551153{
    11561154    return fOrderValue;
     
    11591157- (void) setOrderValue: (int) orderValue
    11601158{
    1161     [fOrderValue release];
    1162     fOrderValue = [[NSNumber alloc] initWithInt: orderValue];
     1159    fOrderValue = orderValue;
    11631160}
    11641161
     
    13651362    else
    13661363        return [NSNumber numberWithInt: 2];
    1367 }
    1368 
    1369 - (NSNumber *) progressSortKey
    1370 {
    1371     return [NSNumber numberWithFloat: [self progress]];
    13721364}
    13731365
Note: See TracChangeset for help on using the changeset viewer.