Ignore:
Timestamp:
Oct 19, 2009, 3:10:29 AM (13 years ago)
Author:
livings124
Message:

when pruning message log messages, sort them in reverse chronological before trimming and use removeObjectsAtIndexes: for assumedly more efficient removal

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.m

    r9325 r9326  
    9797    [fSaveButton setFrame: saveButtonFrame];
    9898   
    99     float oldClearButtonWidth = [fClearButton frame].size.width;
     99    const CGFloat oldClearButtonWidth = [fClearButton frame].size.width;
    100100   
    101101    [fClearButton setTitle: NSLocalizedString(@"Clear", "Message window -> save button")];
     
    171171    if (total > MAX_MESSAGES)
    172172    {
    173         //remove the oldest
    174         NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"Index" ascending: YES] autorelease];
     173        //remove the oldest - move oldest to end for (assumedly) most efficient removal
     174        NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"Index" ascending: NO] autorelease];
    175175        [fMessages sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
    176176       
    177         [fMessages removeObjectsInRange: NSMakeRange(0, total-MAX_MESSAGES)];
     177        [fMessages removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(MAX_MESSAGES, total-MAX_MESSAGES)]];
    178178       
    179179        [fMessageTable noteHeightOfRowsWithIndexesChanged: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, MAX_MESSAGES)]];
Note: See TracChangeset for help on using the changeset viewer.