Changeset 4871


Ignore:
Timestamp:
Jan 30, 2008, 10:14:19 PM (15 years ago)
Author:
livings124
Message:

simplify the code for adding group dividers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r4870 r4871  
    18911891        [fDisplayedTorrents sortUsingDescriptors: [NSArray arrayWithObject: groupDescriptor]];
    18921892       
    1893         int i, groupValue = [[fDisplayedTorrents objectAtIndex: 0] groupValue], newGroupValue, count = 1, start = 0;
     1893        int i, oldGroupValue = -2;
    18941894        for (i = 0; i < [fDisplayedTorrents count]; i++)
    18951895        {
    1896             BOOL last = i == [fDisplayedTorrents count]-1;
    1897             if (!last)
    1898                 newGroupValue = [[fDisplayedTorrents objectAtIndex: i+1] groupValue];
    1899             if (groupValue != newGroupValue || last)
     1896            int groupValue = [[fDisplayedTorrents objectAtIndex: i] groupValue];
     1897            if (groupValue != oldGroupValue)
    19001898            {
    1901                 [fDisplayedTorrents insertObject: [NSNumber numberWithInt: groupValue] atIndex: start];
    1902                 [fDisplayedGroupIndexes addIndex: start];
     1899                [fDisplayedTorrents insertObject: [NSNumber numberWithInt: groupValue] atIndex: i];
     1900                [fDisplayedGroupIndexes addIndex: i];
    19031901               
    1904                 groupValue = newGroupValue;
    1905                 count = 1;
    1906                
    1907                 start = i+2;
    19081902                i++;
     1903                oldGroupValue = groupValue;
    19091904            }
    1910             else
    1911                 count++;
    19121905        }
    19131906    }
Note: See TracChangeset for help on using the changeset viewer.