]> granicus.if.org Git - transmission/commitdiff
when pruning message log messages, sort them in reverse chronological before trimming...
authorMitchell Livingston <livings124@transmissionbt.com>
Mon, 19 Oct 2009 03:10:29 +0000 (03:10 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Mon, 19 Oct 2009 03:10:29 +0000 (03:10 +0000)
macosx/MessageWindowController.m

index 62134fdc9e4c84f1553ee4952ae9c9721d58ac6c..aa322e807e4db87f0750c9ac05ae2ab68207c83a 100644 (file)
@@ -96,7 +96,7 @@
     saveButtonFrame.size.width += 10.0;
     [fSaveButton setFrame: saveButtonFrame];
     
-    float oldClearButtonWidth = [fClearButton frame].size.width;
+    const CGFloat oldClearButtonWidth = [fClearButton frame].size.width;
     
     [fClearButton setTitle: NSLocalizedString(@"Clear", "Message window -> save button")];
     [fClearButton sizeToFit];
     NSUInteger total = [fMessages count];
     if (total > MAX_MESSAGES)
     {
-        //remove the oldest
-        NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"Index" ascending: YES] autorelease];
+        //remove the oldest - move oldest to end for (assumedly) most efficient removal
+        NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"Index" ascending: NO] autorelease];
         [fMessages sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
         
-        [fMessages removeObjectsInRange: NSMakeRange(0, total-MAX_MESSAGES)];
+        [fMessages removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(MAX_MESSAGES, total-MAX_MESSAGES)]];
         
         [fMessageTable noteHeightOfRowsWithIndexesChanged: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, MAX_MESSAGES)]];
         total = MAX_MESSAGES;