small potential speedup for the pieces bar
This commit is contained in:
parent
ff929b1f6a
commit
3eb3d890ec
|
@ -4207,173 +4207,4 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
/*- (void) ipcQuit
|
||||
{
|
||||
fRemoteQuit = YES;
|
||||
[NSApp terminate: self];
|
||||
}
|
||||
|
||||
- (NSArray *) ipcGetTorrentsByID: (NSArray *) idlist
|
||||
{
|
||||
if (!idlist)
|
||||
return fTorrents;
|
||||
|
||||
NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [idlist count]];
|
||||
|
||||
NSEnumerator * torrentEnum = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
while ((torrent = [torrentEnum nextObject]))
|
||||
{
|
||||
int torId = [torrent torrentID];
|
||||
|
||||
NSEnumerator * idEnum = [idlist objectEnumerator];
|
||||
NSNumber * tempId;
|
||||
while ((tempId = [idEnum nextObject]))
|
||||
{
|
||||
if ([tempId intValue] == torId)
|
||||
{
|
||||
[torrents addObject: torrent];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return torrents;
|
||||
}
|
||||
|
||||
- (NSArray *) ipcGetTorrentsByHash: (NSArray *) hashlist
|
||||
{
|
||||
if (!hashlist)
|
||||
return fTorrents;
|
||||
|
||||
NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [hashlist count]];
|
||||
|
||||
NSEnumerator * torrentEnum = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
while ((torrent = [torrentEnum nextObject]))
|
||||
{
|
||||
NSString * torHash = [torrent hashString], * tempHash;
|
||||
|
||||
NSEnumerator * hashEnum = [hashlist objectEnumerator];
|
||||
while ((tempHash = [hashEnum nextObject]))
|
||||
{
|
||||
if ([torHash caseInsensitiveCompare: tempHash] == NSOrderedSame)
|
||||
{
|
||||
[torrents addObject: torrent];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return torrents;
|
||||
}
|
||||
|
||||
- (BOOL) ipcAddTorrents: (NSArray *) torrents
|
||||
{
|
||||
int oldCount = [fTorrents count];
|
||||
|
||||
[self openFiles: torrents addType: ADD_NORMAL forcePath: nil];
|
||||
|
||||
return [fTorrents count] > oldCount;
|
||||
}
|
||||
|
||||
- (BOOL) ipcAddTorrentFile: (NSString *) path directory: (NSString *) directory
|
||||
{
|
||||
int oldCount = [fTorrents count];
|
||||
|
||||
[self openFiles: [NSArray arrayWithObject: path] addType: ADD_NORMAL forcePath: directory];
|
||||
|
||||
return [fTorrents count] > oldCount;
|
||||
}
|
||||
|
||||
- (BOOL) ipcAddTorrentFileAutostart: (NSString *) path directory: (NSString *) directory autostart: (BOOL) autostart
|
||||
{
|
||||
NSArray * torrents = nil;
|
||||
if (autostart)
|
||||
torrents = [fTorrents copy];
|
||||
BOOL success = [self ipcAddTorrentFile: path directory: directory];
|
||||
|
||||
if (success && autostart)
|
||||
{
|
||||
NSEnumerator * enumerator = [torrents reverseObjectEnumerator];
|
||||
Torrent * torrent;
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
if (![torrents containsObject: torrent])
|
||||
break;
|
||||
|
||||
if (torrent)
|
||||
[torrent startTransfer];
|
||||
else
|
||||
success = NO;
|
||||
}
|
||||
|
||||
[torrents release];
|
||||
return success;
|
||||
}
|
||||
|
||||
- (BOOL) ipcAddTorrentData: (NSData *) data directory: (NSString *) directory
|
||||
{
|
||||
return [self ipcAddTorrentDataAutostart: data directory: directory autostart: [fDefaults boolForKey: @"AutoStartDownload"]];
|
||||
}
|
||||
|
||||
- (BOOL) ipcAddTorrentDataAutostart: (NSData *) data directory: (NSString *) directory autostart: (BOOL) autostart
|
||||
{
|
||||
Torrent * torrent;
|
||||
if ((torrent = [[Torrent alloc] initWithData: data location: directory lib: fLib]))
|
||||
{
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
|
||||
if (autostart)
|
||||
[torrent startTransfer];
|
||||
|
||||
[torrent release];
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) ipcStartTorrents: (NSArray *) torrents
|
||||
{
|
||||
if (!torrents)
|
||||
[self resumeAllTorrents: self];
|
||||
else
|
||||
[self resumeTorrents: torrents];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) ipcStopTorrents: (NSArray *) torrents
|
||||
{
|
||||
if (!torrents)
|
||||
[self stopAllTorrents: self];
|
||||
else
|
||||
[self stopTorrents: torrents];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) ipcVerifyTorrents: (NSArray *) torrents
|
||||
{
|
||||
if (!torrents)
|
||||
return NO;
|
||||
|
||||
[self verifyTorrents: torrents];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) ipcRemoveTorrents: (NSArray *) torrents
|
||||
{
|
||||
if (!torrents)
|
||||
torrents = [NSArray arrayWithArray: fTorrents];
|
||||
[torrents retain];
|
||||
|
||||
[self confirmRemoveTorrents: torrents deleteData: NO deleteTorrent: NO];
|
||||
|
||||
return YES;
|
||||
}*/
|
||||
|
||||
@end
|
||||
|
|
|
@ -774,8 +774,8 @@
|
|||
else
|
||||
pieceColor = fBlue4Color;
|
||||
|
||||
if (![pieceColor isEqual: [fBitmap colorAtX: i y: 0]])
|
||||
[fBitmap setColor: pieceColor atX: i y: 0];
|
||||
//it is faster to just set color instead of checking color
|
||||
[fBitmap setColor: pieceColor atX: i y: 0];
|
||||
}
|
||||
|
||||
[torrent setPreviousAmountFinished: piecePercent];
|
||||
|
|
Loading…
Reference in New Issue