1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

simplify the code for adding group dividers

This commit is contained in:
Mitchell Livingston 2008-01-30 22:14:19 +00:00
parent d99e328bab
commit dd64616376

View file

@ -1890,25 +1890,18 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
NSSortDescriptor * groupDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"groupOrderValue" ascending: YES] autorelease];
[fDisplayedTorrents sortUsingDescriptors: [NSArray arrayWithObject: groupDescriptor]];
int i, groupValue = [[fDisplayedTorrents objectAtIndex: 0] groupValue], newGroupValue, count = 1, start = 0;
int i, oldGroupValue = -2;
for (i = 0; i < [fDisplayedTorrents count]; i++)
{
BOOL last = i == [fDisplayedTorrents count]-1;
if (!last)
newGroupValue = [[fDisplayedTorrents objectAtIndex: i+1] groupValue];
if (groupValue != newGroupValue || last)
int groupValue = [[fDisplayedTorrents objectAtIndex: i] groupValue];
if (groupValue != oldGroupValue)
{
[fDisplayedTorrents insertObject: [NSNumber numberWithInt: groupValue] atIndex: start];
[fDisplayedGroupIndexes addIndex: start];
[fDisplayedTorrents insertObject: [NSNumber numberWithInt: groupValue] atIndex: i];
[fDisplayedGroupIndexes addIndex: i];
groupValue = newGroupValue;
count = 1;
start = i+2;
i++;
oldGroupValue = groupValue;
}
else
count++;
}
}