Moved most enumerators to fast enumeration.

CQTexperiment
vspader 2008-02-20 00:54:45 +00:00
parent 00ef56a0ed
commit b15e4f626a
11 changed files with 21 additions and 53 deletions

View File

@ -311,10 +311,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
{
//Need to convert to urls
NSMutableArray *urls = [NSMutableArray array];
NSEnumerator *e = [filenames objectEnumerator];
NSString *filename;
while (filename = [e nextObject])
for (NSString *filename in filenames)
{
[urls addObject:[NSURL fileURLWithPath:filename]];
}

View File

@ -22,10 +22,8 @@
{
NSArray *urls = [AudioContainer urlsForContainerURL:url];
NSURL *u;
NSEnumerator *e = [urls objectEnumerator];
NSMutableArray *paths = [[NSMutableArray alloc] init];
while (u = [e nextObject])
for (NSURL *u in urls)
{
ContainedNode *node = [[ContainedNode alloc] initWithDataSource:dataSource url:u];
NSLog(@"Node: %@", u);

View File

@ -22,9 +22,8 @@
{
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:[url path]] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
NSMutableArray *fullPaths = [[NSMutableArray alloc] init];
NSString *s;
NSEnumerator *e = [contents objectEnumerator];
while (s = [e nextObject])
for (NSString *s in contents)
{
[fullPaths addObject:[[url path] stringByAppendingPathComponent: s]];
}

View File

@ -130,10 +130,8 @@
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray*)items toPasteboard:(NSPasteboard*)pboard {
//Get selected paths
NSMutableArray *urls = [NSMutableArray arrayWithCapacity:[items count]];
NSEnumerator *e = [items objectEnumerator];
id p;
while (p = [e nextObject]) {
for (id p in items) {
[urls addObject:[p url]];
}
NSLog(@"URLS: %@", urls);

View File

@ -89,9 +89,7 @@ NSURL *resolveAliases(NSURL *url)
{
NSMutableArray *newSubpaths = [[NSMutableArray alloc] init];
NSEnumerator *e = [contents objectEnumerator];
NSString *s;
while ((s = [e nextObject]))
for (NSString *s in contents)
{
if ([s characterAtIndex:0] == '.')
{

View File

@ -22,6 +22,5 @@ extern NSString *iTunesDropType;
-(void)moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet*)indexSet toIndex:(unsigned int)insertIndex;
- (NSIndexSet *)indexSetFromRows:(NSArray *)rows;
- (int)rowsAboveRow:(int)row inIndexSet:(NSIndexSet *)indexSet;
@end

View File

@ -138,9 +138,8 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E";
- (NSIndexSet *)indexSetFromRows:(NSArray *)rows
{
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
NSEnumerator *rowEnumerator = [rows objectEnumerator];
NSNumber *idx;
while (idx = [rowEnumerator nextObject])
for (NSNumber *idx in rows)
{
[indexSet addIndex:[idx unsignedIntValue]];
}

View File

@ -122,9 +122,7 @@
if ([bestType isEqualToString:NSFilenamesPboardType]) {
NSMutableArray *urls = [[NSMutableArray alloc] init];
NSEnumerator *e = [[[info draggingPasteboard] propertyListForType:NSFilenamesPboardType] objectEnumerator];
NSString *file;
while (file = [e nextObject])
for (NSString *file in [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType])
{
[urls addObject:[NSURL fileURLWithPath:file]];
}
@ -142,9 +140,7 @@
// Convert the iTunes URLs to URLs....MWAHAHAH!
NSMutableArray *urls = [[NSMutableArray alloc] init];
NSEnumerator *e = [[tracks allValues] objectEnumerator];
NSDictionary *trackInfo;
while (trackInfo = [e nextObject]) {
for (NSDictionary *trackInfo in [tracks allValues]) {
[urls addObject:[NSURL URLWithString:[trackInfo valueForKey:@"Location"]]];
}
@ -166,10 +162,7 @@
double tt = 0;
ldiv_t hoursAndMinutes;
NSEnumerator *enumerator = [[self arrangedObjects] objectEnumerator];
PlaylistEntry* pe;
while (pe = [enumerator nextObject]) {
for (PlaylistEntry *pe in [self arrangedObjects]) {
tt += [[pe length] doubleValue];
}

View File

@ -44,9 +44,7 @@
//find the longest string display length in that column
float max_width = -1;
id row;
NSEnumerator *enumerator = [boundArray objectEnumerator];
while (row = [enumerator nextObject]) {
for (id row in boundArray) {
[cell setObjectValue:row];

View File

@ -76,10 +76,7 @@
}
[fileHandle truncateFileAtOffset:0];
PlaylistEntry *pe;
NSEnumerator *e = [[playlistController content] objectEnumerator];
while (pe = [e nextObject])
for (PlaylistEntry *pe in [playlistController content])
{
NSString *path = [self relativePathFrom:filename toURL:[pe URL]];
[fileHandle writeData:[[path stringByAppendingString:@"\n"] dataUsingEncoding:NSUTF8StringEncoding]];
@ -100,10 +97,8 @@
[fileHandle writeData:[[NSString stringWithFormat:@"[playlist]\nnumberOfEntries=%i\n\n",[[playlistController content] count]] dataUsingEncoding:NSUTF8StringEncoding]];
NSEnumerator *e = [[playlistController content] objectEnumerator];
PlaylistEntry *pe;
int i = 1;
while (pe = [e nextObject])
for (PlaylistEntry *pe in [playlistController content])
{
NSString *path = [self relativePathFrom:filename toURL:[pe URL]];
NSString *entry = [NSString stringWithFormat:@"File%i=%@\n",i,path];
@ -124,11 +119,9 @@
NSMutableArray *urls = [NSMutableArray array];
NSString *subpath;
NSArray *subpaths = [manager subpathsAtPath:path];
NSEnumerator *e = [subpaths objectEnumerator];
while(subpath = [e nextObject])
for(NSString *subpath in subpaths)
{
NSString *absoluteSubpath = [NSString pathWithComponents:[NSArray arrayWithObjects:path,subpath,nil]];
@ -157,9 +150,8 @@
if (index < 0)
index = 0;
NSEnumerator *urlEnumerator = [urls objectEnumerator];
NSURL *url;
while (url = [urlEnumerator nextObject])
for (url in urls)
{
if ([url isFileURL]) {
BOOL isDir;
@ -199,8 +191,7 @@
sortedURLs = [expandedURLs copy];
}
urlEnumerator = [sortedURLs objectEnumerator];
while (url = [urlEnumerator nextObject])
for (url in sortedURLs)
{
//Container vs non-container url
if ([[self acceptableContainerTypes] containsObject:[[[url path] pathExtension] lowercaseString]]) {
@ -219,8 +210,7 @@
NSLog(@"Contained urls: %@", containedURLs);
urlEnumerator = [fileURLs objectEnumerator];
while (url = [urlEnumerator nextObject])
for (url in fileURLs)
{
if (![[AudioPlayer schemes] containsObject:[url scheme]])
continue;
@ -239,8 +229,7 @@
NSLog(@"Valid urls: %@", validURLs);
urlEnumerator = [containedURLs objectEnumerator];
while (url = [urlEnumerator nextObject])
for (url in containedURLs)
{
if (![[AudioPlayer schemes] containsObject:[url scheme]])
continue;
@ -286,9 +275,8 @@
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSEnumerator *e = [entries objectEnumerator];
PlaylistEntry *pe;
while (pe = [e nextObject])
for (pe in entries)
{
[pe readPropertiesThread];

2
TODO
View File

@ -1 +1 @@
Get rid of negative index nonsense for removed playlist entry, instead just add a "removed" BOOL that gets set and can be checked.