From ce8a1c230dde1ef6fc28988650d90fd334cab959 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 6 Apr 2021 16:50:17 -0700 Subject: [PATCH] Fix Playlist Loader so it only attempts to process track info for tracks that need it, and not the entire playlist every time --- Playlist/PlaylistLoader.m | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 27bb8d6ee..3788c5082 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -309,7 +309,7 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL } else { - [expandedURLs addObject:url]; + [expandedURLs addObject:[NSURL fileURLWithPath:[url path]]]; } } } @@ -472,14 +472,19 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL - (void)syncLoadInfoForEntries:(NSArray *)entries { NSMutableIndexSet *update_indexes = [[NSMutableIndexSet alloc] init]; - long i; + long i, j; + NSMutableIndexSet *load_info_indexes = [[NSMutableIndexSet alloc] init]; i = 0; + j = 0; for (PlaylistEntry *pe in entries) { + long idx = j++; + if ([pe metadataLoaded]) continue; [update_indexes addIndex:pe.index]; + [load_info_indexes addIndex:idx]; ++i; } @@ -490,21 +495,21 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL return; } - { - for (PlaylistEntry *pe in entries) + [load_info_indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) { + PlaylistEntry *pe = [entries objectAtIndex:idx]; + NSMutableDictionary *entryInfo = [NSMutableDictionary dictionaryWithCapacity:20]; NSDictionary *entryProperties = [AudioPropertiesReader propertiesForURL:pe.URL]; if (entryProperties == nil) - continue; + return; [entryInfo addEntriesFromDictionary:entryProperties]; [entryInfo addEntriesFromDictionary:[AudioMetadataReader metadataForURL:pe.URL]]; [pe setMetadata:entryInfo]; - } - } + }]; [self->playlistController updateTotalTime];