1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

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

This commit is contained in:
Mitchell Livingston 2009-12-10 04:49:57 +00:00
parent 3d30bb32d5
commit b739e72f0f
2 changed files with 6 additions and 6 deletions

View file

@ -32,7 +32,6 @@
IBOutlet NSButton * fSaveButton, * fClearButton;
NSMutableArray * fMessages, * fDisplayedMessages;
NSUInteger fCurrentIndex;
NSDictionary * fAttributes;

View file

@ -155,8 +155,10 @@
[fLock lock];
NSUInteger currentCount = [fMessages count];
NSScroller * scroller = [[fMessageTable enclosingScrollView] verticalScroller];
const BOOL shouldScroll = fCurrentIndex == 0 || [scroller floatValue] == 1.0 || [scroller isHidden]
const BOOL shouldScroll = currentCount == 0 || [scroller floatValue] == 1.0 || [scroller isHidden]
|| [scroller knobProportion] == 1.0;
const NSInteger maxLevel = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"];
@ -173,7 +175,7 @@
NSDictionary * message = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithUTF8String: currentMessage->message], @"Message",
[NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
[NSNumber numberWithUnsignedInteger: fCurrentIndex++], @"Index", //more accurate when sorting by date
[NSNumber numberWithUnsignedInteger: currentCount++], @"Index", //more accurate when sorting by date
[NSNumber numberWithInteger: currentMessage->level], @"Level",
name, @"Name",
file, @"File", nil];
@ -187,9 +189,9 @@
}
}
if ([fMessages count] > TR_MAX_MSG_LOG)
if (currentCount > TR_MAX_MSG_LOG)
{
NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fMessages count]-TR_MAX_MSG_LOG)];
NSIndexSet * removeIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, currentCount-TR_MAX_MSG_LOG)];
NSArray * itemsToRemove = [fMessages objectsAtIndexes: removeIndexes];
[fMessages removeObjectsAtIndexes: removeIndexes];
@ -359,7 +361,6 @@
[fMessages removeAllObjects];
[fDisplayedMessages removeAllObjects];
[fMessageTable reloadData];
fCurrentIndex = 0;
[fLock unlock];
}