Changeset 9699


Ignore:
Timestamp:
Dec 10, 2009, 4:49:57 AM (12 years ago)
Author:
livings124
Message:

on second thought, there's no need to store the index at all - it's just the number of messages we have

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.h

    r9698 r9699  
    3333   
    3434    NSMutableArray * fMessages, * fDisplayedMessages;
    35     NSUInteger fCurrentIndex;
    3635   
    3736    NSDictionary * fAttributes;
  • trunk/macosx/MessageWindowController.m

    r9698 r9699  
    156156    [fLock lock];
    157157   
     158    NSUInteger currentCount = [fMessages count];
     159   
    158160    NSScroller * scroller = [[fMessageTable enclosingScrollView] verticalScroller];
    159     const BOOL shouldScroll = fCurrentIndex == 0 || [scroller floatValue] == 1.0 || [scroller isHidden]
     161    const BOOL shouldScroll = currentCount == 0 || [scroller floatValue] == 1.0 || [scroller isHidden]
    160162                                || [scroller knobProportion] == 1.0;
    161163   
     
    174176                                    [NSString stringWithUTF8String: currentMessage->message], @"Message",
    175177                                    [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
    176                                     [NSNumber numberWithUnsignedInteger: fCurrentIndex++], @"Index", //more accurate when sorting by date
     178                                    [NSNumber numberWithUnsignedInteger: currentCount++], @"Index", //more accurate when sorting by date
    177179                                    [NSNumber numberWithInteger: currentMessage->level], @"Level",
    178180                                    name, @"Name",
     
    188190    }
    189191   
    190     if ([fMessages count] > TR_MAX_MSG_LOG)
    191     {
    192         NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_MAX_MSG_LOG)];
     192    if (currentCount > TR_MAX_MSG_LOG)
     193    {
     194        NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, currentCount-TR_MAX_MSG_LOG)];
    193195        NSArray * itemsToRemove = [fMessages objectsAtIndexes: removeIndexes];
    194196       
     
    360362    [fDisplayedMessages removeAllObjects];
    361363    [fMessageTable reloadData];
    362     fCurrentIndex = 0;
    363364   
    364365    [fLock unlock];
Note: See TracChangeset for help on using the changeset viewer.