mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
get rid of unneeded sort descriptors; hold queue order as an integer instead of an object
This commit is contained in:
parent
ebc8f34f48
commit
dc37d150e8
3 changed files with 15 additions and 24 deletions
|
@ -1144,7 +1144,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
while ((torrent = [enumerator nextObject]))
|
||||
[torrent setWaitToStart: NO];
|
||||
|
||||
NSNumber * lowestOrderValue = nil, * currentOrderValue;
|
||||
int lowestOrderValue = -1, currentOrderValue;
|
||||
|
||||
enumerator = [torrents objectEnumerator];
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
|
@ -1158,7 +1158,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
|
||||
//determine lowest order value
|
||||
currentOrderValue = [torrent orderValue];
|
||||
if (!lowestOrderValue || [lowestOrderValue compare: currentOrderValue] == NSOrderedDescending)
|
||||
if (lowestOrderValue < currentOrderValue)
|
||||
lowestOrderValue = currentOrderValue;
|
||||
|
||||
[torrent closeRemoveTorrent];
|
||||
|
@ -1168,7 +1168,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[torrents release];
|
||||
|
||||
//reset the order values if necessary
|
||||
if ([lowestOrderValue intValue] < [fTorrents count])
|
||||
if (lowestOrderValue < [fTorrents count])
|
||||
{
|
||||
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"orderValue" ascending: YES] autorelease];
|
||||
|
@ -1178,7 +1178,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[descriptors release];
|
||||
|
||||
int i;
|
||||
for (i = [lowestOrderValue intValue]; i < [tempTorrents count]; i++)
|
||||
for (i = lowestOrderValue; i < [tempTorrents count]; i++)
|
||||
[[tempTorrents objectAtIndex: i] setOrderValue: i];
|
||||
}
|
||||
|
||||
|
@ -1602,7 +1602,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"stateSortKey" ascending: !asc] autorelease],
|
||||
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"progressSortKey" ascending: !asc] autorelease],
|
||||
@"progress" ascending: !asc] autorelease],
|
||||
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"ratioSortKey" ascending: !asc] autorelease];
|
||||
|
||||
|
@ -1612,7 +1612,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
else if ([sortType isEqualToString: SORT_PROGRESS])
|
||||
{
|
||||
NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"progressSortKey" ascending: asc] autorelease],
|
||||
@"progress" ascending: asc] autorelease],
|
||||
* ratioProgressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"ratioProgressSortKey" ascending: asc] autorelease],
|
||||
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
|
@ -2189,7 +2189,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
newRow--;
|
||||
|
||||
//reinsert into array
|
||||
int insertIndex = newRow > 0 ? [[[fDisplayedTorrents objectAtIndex: newRow-1] orderValue] intValue] + 1 : 0;
|
||||
int insertIndex = newRow > 0 ? [[fDisplayedTorrents objectAtIndex: newRow-1] orderValue] + 1 : 0;
|
||||
|
||||
//get all torrents to reorder
|
||||
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
|
|
|
@ -61,11 +61,11 @@ typedef enum
|
|||
|
||||
NSMenu * fFileMenu;
|
||||
|
||||
float fRatioLimit;
|
||||
int fRatioSetting;
|
||||
BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
|
||||
float fRatioLimit;
|
||||
int fRatioSetting;
|
||||
BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
|
||||
|
||||
NSNumber * fOrderValue;
|
||||
int fOrderValue;
|
||||
|
||||
NSDictionary * fQuickPauseDict;
|
||||
|
||||
|
@ -201,7 +201,7 @@ typedef enum
|
|||
- (BOOL) pex;
|
||||
- (void) setPex: (BOOL) enable;
|
||||
|
||||
- (NSNumber *) orderValue;
|
||||
- (int) orderValue;
|
||||
- (void) setOrderValue: (int) orderValue;
|
||||
|
||||
- (NSArray *) fileList;
|
||||
|
@ -229,7 +229,6 @@ typedef enum
|
|||
- (BOOL) isStalled;
|
||||
|
||||
- (NSNumber *) stateSortKey;
|
||||
- (NSNumber *) progressSortKey;
|
||||
- (NSNumber *) ratioSortKey;
|
||||
- (NSNumber *) ratioProgressSortKey;
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
[NSNumber numberWithInt: fRatioSetting], @"RatioSetting",
|
||||
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
|
||||
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
||||
[self orderValue], @"OrderValue", nil];
|
||||
[NSNumber numberWithInt: fOrderValue], @"OrderValue", nil];
|
||||
|
||||
if (fIncompleteFolder)
|
||||
[history setObject: fIncompleteFolder forKey: @"IncompleteFolder"];
|
||||
|
@ -162,8 +162,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
[fFileList release];
|
||||
[fFileMenu release];
|
||||
|
||||
[fOrderValue release];
|
||||
|
||||
[fQuickPauseDict release];
|
||||
|
||||
[super dealloc];
|
||||
|
@ -1151,15 +1149,14 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
tr_torrentDisablePex(fHandle, !enable);
|
||||
}
|
||||
|
||||
- (NSNumber *) orderValue
|
||||
- (int) orderValue
|
||||
{
|
||||
return fOrderValue;
|
||||
}
|
||||
|
||||
- (void) setOrderValue: (int) orderValue
|
||||
{
|
||||
[fOrderValue release];
|
||||
fOrderValue = [[NSNumber alloc] initWithInt: orderValue];
|
||||
fOrderValue = orderValue;
|
||||
}
|
||||
|
||||
- (NSArray *) fileList
|
||||
|
@ -1366,11 +1363,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
return [NSNumber numberWithInt: 2];
|
||||
}
|
||||
|
||||
- (NSNumber *) progressSortKey
|
||||
{
|
||||
return [NSNumber numberWithFloat: [self progress]];
|
||||
}
|
||||
|
||||
- (NSNumber *) ratioSortKey
|
||||
{
|
||||
return [NSNumber numberWithFloat: [self ratio]];
|
||||
|
|
Loading…
Add table
Reference in a new issue