mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
move a lot of loop counters into the loops' scopes; trivial changes
This commit is contained in:
parent
b2f1937074
commit
9d5430a381
10 changed files with 75 additions and 116 deletions
|
@ -289,8 +289,7 @@
|
|||
{
|
||||
NSMenu * menu = [fGroupPopUp menu];
|
||||
|
||||
int i;
|
||||
for (i = [menu numberOfItems]-1 - 2; i >= 0; i--)
|
||||
for (NSInteger i = [menu numberOfItems]-1 - 2; i >= 0; i--)
|
||||
[menu removeItemAtIndex: i];
|
||||
|
||||
NSMenu * groupMenu = [[GroupsController groups] groupMenuWithTarget: self action: @selector(changeGroupValue:) isSmall: NO];
|
||||
|
|
|
@ -634,8 +634,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
NSAppleEventDescriptor * directObject = [event paramDescriptorForKeyword: keyDirectObject];
|
||||
if ([directObject descriptorType] == typeAEList)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 1; i <= [directObject numberOfItems]; i++)
|
||||
for (NSUInteger i = 1; i <= [directObject numberOfItems]; i++)
|
||||
if ((urlString = [[directObject descriptorAtIndex: i] stringValue]))
|
||||
break;
|
||||
}
|
||||
|
@ -1283,8 +1282,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
//reset the order values if necessary
|
||||
if (lowestOrderValue < [fTorrents count])
|
||||
{
|
||||
int i;
|
||||
for (i = lowestOrderValue; i < [fTorrents count]; i++)
|
||||
for (int i = lowestOrderValue; i < [fTorrents count]; i++)
|
||||
[[fTorrents objectAtIndex: i] setOrderValue: i];
|
||||
}
|
||||
|
||||
|
@ -1961,10 +1959,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
//get count of each type
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
int i = -1;
|
||||
int index = -1;
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
{
|
||||
i++;
|
||||
index++;
|
||||
|
||||
//check status
|
||||
if ([torrent isActive] && ![torrent isCheckingWaiting])
|
||||
|
@ -2029,7 +2027,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
}
|
||||
|
||||
[indexes addIndex: i];
|
||||
[indexes addIndex: index];
|
||||
}
|
||||
|
||||
NSArray * allTorrents = [fTorrents objectsAtIndexes: indexes];
|
||||
|
@ -2057,8 +2055,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
allTorrents = [allTorrents sortedArrayUsingDescriptors: [NSArray arrayWithObject: groupDescriptor]];
|
||||
|
||||
NSMutableArray * groupTorrents;
|
||||
int oldGroupValue = -2;
|
||||
for (i = 0; i < [allTorrents count]; i++)
|
||||
for (int i = 0, oldGroupValue = -2; i < [allTorrents count]; i++)
|
||||
{
|
||||
torrent = [allTorrents objectAtIndex: i];
|
||||
int groupValue = [torrent groupValue];
|
||||
|
@ -2229,8 +2226,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
if (menu == fGroupsSetMenu || menu == fGroupsSetContextMenu)
|
||||
{
|
||||
int i;
|
||||
for (i = [menu numberOfItems]-1 - 2; i >= 0; i--)
|
||||
for (int i = [menu numberOfItems]-1 - 2; i >= 0; i--)
|
||||
[menu removeItemAtIndex: i];
|
||||
|
||||
NSMenu * groupMenu = [[GroupsController groups] groupMenuWithTarget: self action: @selector(setGroup:) isSmall: NO];
|
||||
|
@ -2239,8 +2235,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
else if (menu == fGroupFilterMenu)
|
||||
{
|
||||
int i;
|
||||
for (i = [menu numberOfItems]-1; i >= 3; i--)
|
||||
for (int i = [menu numberOfItems]-1; i >= 3; i--)
|
||||
[menu removeItemAtIndex: i];
|
||||
|
||||
NSMenu * groupMenu = [[GroupsController groups] groupMenuWithTarget: self action: @selector(setGroupFilter:)
|
||||
|
@ -2256,8 +2251,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
const int speedLimitActionValue[] = { 5, 10, 20, 30, 40, 50, 75, 100, 150, 200, 250, 500, 750, -1 };
|
||||
|
||||
NSMenuItem * item;
|
||||
int i;
|
||||
for (i = 0; speedLimitActionValue[i] != -1; i++)
|
||||
for (int i = 0; speedLimitActionValue[i] != -1; i++)
|
||||
{
|
||||
item = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: NSLocalizedString(@"%d KB/s",
|
||||
"Action menu -> upload/download limit"), speedLimitActionValue[i]] action: @selector(setQuickLimitGlobal:)
|
||||
|
@ -2276,8 +2270,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
const float ratioLimitActionValue[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, -1 };
|
||||
|
||||
NSMenuItem * item;
|
||||
int i;
|
||||
for (i = 0; ratioLimitActionValue[i] != -1; i++)
|
||||
for (int i = 0; ratioLimitActionValue[i] != -1; i++)
|
||||
{
|
||||
item = [[NSMenuItem alloc] initWithTitle: [NSString localizedStringWithFormat: @"%.2f", ratioLimitActionValue[i]]
|
||||
action: @selector(setQuickRatioGlobal:) keyEquivalent: @""];
|
||||
|
@ -2545,8 +2538,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[fAutoImportedNames setArray: importedNames];
|
||||
|
||||
NSString * file;
|
||||
int i;
|
||||
for (i = [newNames count] - 1; i >= 0; i--)
|
||||
for (int i = [newNames count] - 1; i >= 0; i--)
|
||||
{
|
||||
file = [newNames objectAtIndex: i];
|
||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
|
||||
|
@ -2750,8 +2742,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
//get the torrents to move
|
||||
NSMutableArray * movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]];
|
||||
int i;
|
||||
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
for (int i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
[movingTorrents addObject: [fTableView itemAtRow: i]];
|
||||
|
||||
//reset groups
|
||||
|
@ -2779,7 +2770,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
//find torrent to place under
|
||||
NSArray * groupTorrents = item ? [item torrents] : fDisplayedTorrents;
|
||||
Torrent * topTorrent = nil;
|
||||
for (i = newRow-1; i >= 0; i--)
|
||||
for (int i = newRow-1; i >= 0; i--)
|
||||
{
|
||||
Torrent * tempTorrent = [groupTorrents objectAtIndex: i];
|
||||
if (![movingTorrents containsObject: tempTorrent])
|
||||
|
@ -2798,7 +2789,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[fTorrents insertObjects: movingTorrents atIndexes: insertIndexes];
|
||||
|
||||
//redo order values
|
||||
for (i = 0; i < [fTorrents count]; i++)
|
||||
for (int i = 0; i < [fTorrents count]; i++)
|
||||
[[fTorrents objectAtIndex: i] setOrderValue: i];
|
||||
}
|
||||
|
||||
|
@ -4171,8 +4162,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
NSString * fullPath = [url path];
|
||||
NSRange visibleRows = [fTableView rowsInRect: [fTableView bounds]];
|
||||
|
||||
int row;
|
||||
for (row = 0; row < NSMaxRange(visibleRows); row++)
|
||||
for (int row = 0; row < NSMaxRange(visibleRows); row++)
|
||||
{
|
||||
id item = [fTableView itemAtRow: row];
|
||||
if ([item isKindOfClass: [Torrent class]] && [[(Torrent *)item dataLocation] isEqualToString: fullPath])
|
||||
|
|
|
@ -225,8 +225,7 @@ typedef enum
|
|||
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
|
||||
int i;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
[itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
|
||||
|
||||
[fTorrent setFileCheckState: state forIndexes: itemIndexes];
|
||||
|
@ -237,8 +236,7 @@ typedef enum
|
|||
{
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
|
||||
int i;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
[itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
|
||||
|
||||
[fTorrent setFileCheckState: NSOnState forIndexes: itemIndexes];
|
||||
|
@ -267,8 +265,7 @@ typedef enum
|
|||
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
|
||||
int i;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
[itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
|
||||
|
||||
[fTorrent setFilePriority: priority forIndexes: itemIndexes];
|
||||
|
@ -279,8 +276,7 @@ typedef enum
|
|||
{
|
||||
NSString * folder = [fTorrent downloadFolder];
|
||||
NSIndexSet * indexes = [fOutline selectedRowIndexes];
|
||||
int i;
|
||||
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
[[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent:
|
||||
[[fOutline itemAtRow: i] fullPath]] inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
@ -297,8 +293,7 @@ typedef enum
|
|||
{
|
||||
NSString * downloadFolder = [fTorrent downloadFolder];
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
int i;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:
|
||||
[downloadFolder stringByAppendingPathComponent: [[[fTorrent fileList] objectAtIndex: i] fullPath]]])
|
||||
return YES;
|
||||
|
@ -312,10 +307,10 @@ typedef enum
|
|||
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
|
||||
int i, state = ([menuItem tag] == FILE_CHECK_TAG) ? NSOnState : NSOffState;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
[itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
|
||||
|
||||
NSInteger state = ([menuItem tag] == FILE_CHECK_TAG) ? NSOnState : NSOffState;
|
||||
return [fTorrent checkForFiles: itemIndexes] != state && [fTorrent canChangeDownloadCheckForFiles: itemIndexes];
|
||||
}
|
||||
|
||||
|
@ -326,8 +321,7 @@ typedef enum
|
|||
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
|
||||
int i;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
|
||||
[itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
|
||||
|
||||
return [fTorrent canChangeDownloadCheckForFiles: itemIndexes];
|
||||
|
@ -343,9 +337,7 @@ typedef enum
|
|||
|
||||
//determine which priorities are checked
|
||||
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
|
||||
BOOL current = NO, other = NO;
|
||||
int i, priority;
|
||||
|
||||
NSInteger priority;
|
||||
switch ([menuItem tag])
|
||||
{
|
||||
case FILE_PRIORITY_HIGH_TAG:
|
||||
|
@ -358,20 +350,21 @@ typedef enum
|
|||
priority = TR_PRI_LOW;
|
||||
}
|
||||
|
||||
BOOL current = NO, canChange = NO;
|
||||
NSIndexSet * fileIndexSet;
|
||||
for (i = [indexSet firstIndex]; i != NSNotFound && (!current || !other); i = [indexSet indexGreaterThanIndex: i])
|
||||
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound && !current; i = [indexSet indexGreaterThanIndex: i])
|
||||
{
|
||||
fileIndexSet = [[fOutline itemAtRow: i] indexes];
|
||||
if (![fTorrent canChangeDownloadCheckForFiles: fileIndexSet])
|
||||
continue;
|
||||
else if ([fTorrent hasFilePriority: priority forIndexes: fileIndexSet])
|
||||
|
||||
canChange = YES;
|
||||
if ([fTorrent hasFilePriority: priority forIndexes: fileIndexSet])
|
||||
current = YES;
|
||||
else
|
||||
other = YES;
|
||||
}
|
||||
|
||||
[menuItem setState: current ? NSOnState : NSOffState];
|
||||
return current || other;
|
||||
return canChange;
|
||||
}
|
||||
|
||||
return YES;
|
||||
|
|
|
@ -139,11 +139,9 @@
|
|||
if (visibleRows.length == 0)
|
||||
return;
|
||||
|
||||
int col = [self columnWithIdentifier: @"Priority"];
|
||||
NSPoint mouseLocation = [self convertPoint: [[self window] convertScreenToBase: [NSEvent mouseLocation]] fromView: nil];
|
||||
|
||||
int row;
|
||||
for (row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
|
||||
for (NSInteger row = visibleRows.location, col = [self columnWithIdentifier: @"Priority"]; row < NSMaxRange(visibleRows); row++)
|
||||
{
|
||||
FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: col row: row];
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
[self setControlSize: NSMiniControlSize];
|
||||
[self setSegmentCount: 3];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < [self segmentCount]; i++)
|
||||
for (NSInteger i = 0; i < [self segmentCount]; i++)
|
||||
{
|
||||
[self setLabel: @"" forSegment: i];
|
||||
[self setWidth: 9.0 forSegment: i]; //9 is minimum size to get proper look
|
||||
|
@ -105,7 +104,7 @@
|
|||
FileListNode * node = [self representedObject];
|
||||
NSSet * priorities = [torrent filePrioritiesForIndexes: [node indexes]];
|
||||
|
||||
int count = [priorities count];
|
||||
const NSUInteger count = [priorities count];
|
||||
if (fHoverRow && count > 0)
|
||||
{
|
||||
[super setSelected: [priorities containsObject: [NSNumber numberWithInt: TR_PRI_LOW]] forSegment: 0];
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
{
|
||||
NSSegmentedControl * control = (NSSegmentedControl *)[self view];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < [control segmentCount]; i++)
|
||||
for (NSInteger i = 0; i < [control segmentCount]; i++)
|
||||
[control setEnabled: [[self target] validateToolbarItem:
|
||||
[[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]] forSegment: i];
|
||||
}
|
||||
|
@ -56,11 +55,10 @@
|
|||
|
||||
[menu setAutoenablesItems: NO];
|
||||
|
||||
NSMenuItem * addItem;
|
||||
int i, count = [(NSSegmentedControl *)[self view] segmentCount];
|
||||
for (i = 0; i < count; i++)
|
||||
const NSInteger count = [(NSSegmentedControl *)[self view] segmentCount];
|
||||
for (NSInteger i = 0; i < count; i++)
|
||||
{
|
||||
addItem = [[NSMenuItem alloc] initWithTitle: [labels objectAtIndex: i] action: [self action] keyEquivalent: @""];
|
||||
NSMenuItem * addItem = [[NSMenuItem alloc] initWithTitle: [labels objectAtIndex: i] action: [self action] keyEquivalent: @""];
|
||||
[addItem setTarget: [self target]];
|
||||
[addItem setTag: i];
|
||||
|
||||
|
@ -77,8 +75,8 @@
|
|||
{
|
||||
NSMenuItem * menuItem = [super menuFormRepresentation];
|
||||
|
||||
int i, count = [(NSSegmentedControl *)[self view] segmentCount];
|
||||
for (i = 0; i < count; i++)
|
||||
const NSInteger count = [(NSSegmentedControl *)[self view] segmentCount];
|
||||
for (NSInteger i = 0; i < count; i++)
|
||||
[[[menuItem submenu] itemAtIndex: i] setEnabled: [[self target] validateToolbarItem:
|
||||
[[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]]];
|
||||
|
||||
|
|
|
@ -1087,9 +1087,8 @@ typedef enum
|
|||
NSString * folder = [torrent downloadFolder];
|
||||
NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
|
||||
NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [indexes count]];
|
||||
|
||||
int i;
|
||||
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
|
||||
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
{
|
||||
FileListNode * item = [fileOutlineView itemAtRow: i];
|
||||
if ([self canQuickLookFile: item])
|
||||
|
@ -1104,8 +1103,7 @@ typedef enum
|
|||
FileOutlineView * fileOutlineView = [fFileController outlineView];
|
||||
NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
|
||||
|
||||
int i;
|
||||
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
if ([self canQuickLookFile: [fileOutlineView itemAtRow: i]])
|
||||
return YES;
|
||||
|
||||
|
@ -1120,8 +1118,7 @@ typedef enum
|
|||
NSString * folder = [[fTorrents objectAtIndex: 0] downloadFolder];
|
||||
NSRange visibleRows = [fileOutlineView rowsInRect: [fileOutlineView bounds]];
|
||||
|
||||
int row;
|
||||
for (row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
|
||||
for (NSUInteger row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
|
||||
{
|
||||
FileListNode * rowItem = [fileOutlineView itemAtRow: row];
|
||||
if ([[folder stringByAppendingPathComponent: [rowItem fullPath]] isEqualToString: fullPath])
|
||||
|
@ -1638,23 +1635,20 @@ typedef enum
|
|||
{
|
||||
[[self window] makeKeyWindow];
|
||||
|
||||
int i;
|
||||
NSUInteger index = 1;
|
||||
if ([[fTorrents objectAtIndex: 0] hasAddedTrackers])
|
||||
{
|
||||
for (i = 1; i < [fTrackers count]; i++)
|
||||
if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
|
||||
for (; index < [fTrackers count]; index++)
|
||||
if ([[fTrackers objectAtIndex: index] isKindOfClass: [NSNumber class]])
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
[fTrackers insertObject: [NSNumber numberWithInt: 0] atIndex: 0];
|
||||
i = 1;
|
||||
}
|
||||
|
||||
[fTrackers insertObject: @"" atIndex: i];
|
||||
[fTrackers insertObject: @"" atIndex: index];
|
||||
[fTrackerTable reloadData];
|
||||
[fTrackerTable selectRow: i byExtendingSelection: NO];
|
||||
[fTrackerTable editColumn: 0 row: i withEvent: nil select: YES];
|
||||
[fTrackerTable selectRow: index byExtendingSelection: NO];
|
||||
[fTrackerTable editColumn: 0 row: index withEvent: nil select: YES];
|
||||
}
|
||||
|
||||
- (void) removeTrackers
|
||||
|
|
|
@ -148,11 +148,11 @@
|
|||
|
||||
- (void) updateLog: (NSTimer *) timer
|
||||
{
|
||||
tr_msg_list * messages, * currentMessage;
|
||||
tr_msg_list * messages;
|
||||
if ((messages = tr_getQueuedMessages()) == NULL)
|
||||
return;
|
||||
|
||||
for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
||||
for (tr_msg_list * currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
||||
{
|
||||
NSString * name = currentMessage->name != NULL ? [NSString stringWithUTF8String: currentMessage->name]
|
||||
: [[NSProcessInfo processInfo] processName];
|
||||
|
|
|
@ -130,12 +130,12 @@
|
|||
|
||||
NSImage * image = [self image];
|
||||
|
||||
int i, j, index = -1;
|
||||
int index = -1;
|
||||
NSRect rect = NSMakeRect(0, 0, fWidth, fWidth);
|
||||
BOOL change = NO;
|
||||
|
||||
for (i = 0; i < fAcross; i++)
|
||||
for (j = 0; j < fAcross; j++)
|
||||
for (NSInteger i = 0; i < fAcross; i++)
|
||||
for (NSInteger j = 0; j < fAcross; j++)
|
||||
{
|
||||
index++;
|
||||
if (index >= fNumPieces)
|
||||
|
|
|
@ -557,8 +557,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
[self updateFileStat];
|
||||
|
||||
//determine amount needed
|
||||
int i;
|
||||
for (i = 0; i < [self fileCount]; i++)
|
||||
for (int i = 0; i < [self fileCount]; i++)
|
||||
{
|
||||
if (tr_torrentGetFileDL(fHandle, i))
|
||||
{
|
||||
|
@ -791,8 +790,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
capacity += fInfo->trackers[count-1].tier + 1;
|
||||
NSMutableArray * allTrackers = [NSMutableArray arrayWithCapacity: capacity];
|
||||
|
||||
int i, tier = -1;
|
||||
for (i = 0; i < count; i++)
|
||||
for (int i = 0, tier = -1; i < count; i++)
|
||||
{
|
||||
if (separators && tier != fInfo->trackers[i].tier)
|
||||
{
|
||||
|
@ -1000,12 +998,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
- (NSArray *) peers
|
||||
{
|
||||
int totalPeers, i;
|
||||
int totalPeers;
|
||||
tr_peer_stat * peers = tr_torrentPeers(fHandle, &totalPeers);
|
||||
|
||||
NSMutableArray * peerDicts = [NSMutableArray arrayWithCapacity: totalPeers];
|
||||
|
||||
for (i = 0; i < totalPeers; i++)
|
||||
for (int i = 0; i < totalPeers; i++)
|
||||
{
|
||||
tr_peer_stat * peer = &peers[i];
|
||||
NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 9];
|
||||
|
@ -1038,12 +1036,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
- (NSArray *) webSeeds
|
||||
{
|
||||
int webSeedCount = fInfo->webseedCount, i;
|
||||
const int webSeedCount = fInfo->webseedCount;
|
||||
NSMutableArray * webSeeds = [NSMutableArray arrayWithCapacity: webSeedCount];
|
||||
|
||||
float * dlSpeeds = tr_torrentWebSpeeds(fHandle);
|
||||
|
||||
for (i = 0; i < webSeedCount; i++)
|
||||
for (int i = 0; i < webSeedCount; i++)
|
||||
{
|
||||
NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 2];
|
||||
|
||||
|
@ -1445,14 +1443,14 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
NSIndexSet * indexSet = [node indexes];
|
||||
|
||||
if (![node isFolder])
|
||||
if ([indexSet count] == 1)
|
||||
return fFileStat[[indexSet firstIndex]].progress;
|
||||
|
||||
uint64_t have = 0;
|
||||
int index;
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
for (int index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
have += fFileStat[index].bytesCompleted;
|
||||
|
||||
NSAssert([node size], @"director in torrent file has size 0");
|
||||
return (float)have / [node size];
|
||||
}
|
||||
|
||||
|
@ -1472,8 +1470,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
if (!fFileStat)
|
||||
[self updateFileStat];
|
||||
|
||||
int index;
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
for (int index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
if (fFileStat[index].progress < 1.0)
|
||||
return YES;
|
||||
return NO;
|
||||
|
@ -1482,8 +1479,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
- (int) checkForFiles: (NSIndexSet *) indexSet
|
||||
{
|
||||
BOOL onState = NO, offState = NO;
|
||||
int index;
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
for (int index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
{
|
||||
if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFile: index])
|
||||
onState = YES;
|
||||
|
@ -1498,13 +1494,10 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet
|
||||
{
|
||||
NSUInteger count = [indexSet count], i = 0, index;
|
||||
NSUInteger count = [indexSet count];
|
||||
tr_file_index_t * files = malloc(count * sizeof(tr_file_index_t));
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
{
|
||||
for (NSUInteger index = [indexSet firstIndex], i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index], i++)
|
||||
files[i] = index;
|
||||
i++;
|
||||
}
|
||||
|
||||
tr_torrentSetFileDLs(fHandle, files, count, state != NSOffState);
|
||||
free(files);
|
||||
|
@ -1515,13 +1508,10 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet
|
||||
{
|
||||
NSUInteger count = [indexSet count], i = 0, index;
|
||||
const NSUInteger count = [indexSet count];
|
||||
tr_file_index_t * files = malloc(count * sizeof(tr_file_index_t));
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
{
|
||||
for (NSUInteger index = [indexSet firstIndex], i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index], i++)
|
||||
files[i] = index;
|
||||
i++;
|
||||
}
|
||||
|
||||
tr_torrentSetFilePriorities(fHandle, files, count, priority);
|
||||
free(files);
|
||||
|
@ -1529,8 +1519,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet
|
||||
{
|
||||
int index;
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
for (int index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
if (priority == tr_torrentGetFilePriority(fHandle, index) && [self canChangeDownloadCheckForFile: index])
|
||||
return YES;
|
||||
return NO;
|
||||
|
@ -1541,13 +1530,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
BOOL low = NO, normal = NO, high = NO;
|
||||
NSMutableSet * priorities = [NSMutableSet setWithCapacity: 3];
|
||||
|
||||
int index, priority;
|
||||
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
for (int index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||
{
|
||||
if (![self canChangeDownloadCheckForFile: index])
|
||||
continue;
|
||||
|
||||
priority = tr_torrentGetFilePriority(fHandle, index);
|
||||
int priority = tr_torrentGetFilePriority(fHandle, index);
|
||||
if (priority == TR_PRI_LOW)
|
||||
{
|
||||
if (low)
|
||||
|
@ -1753,10 +1741,10 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
{
|
||||
if ([self isFolder])
|
||||
{
|
||||
int count = [self fileCount], i;
|
||||
int count = [self fileCount];
|
||||
NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
tr_file * file = &fInfo->files[i];
|
||||
|
||||
|
|
Loading…
Reference in a new issue