Remove the meta string cache

It wasn't helping anyway.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
xcode15
Christopher Snowhill 2022-07-08 07:18:33 -07:00
parent 375eae4be2
commit ef0dd921ab
1 changed files with 1 additions and 29 deletions

View File

@ -19,16 +19,8 @@
extern NSPersistentContainer *kPersistentContainer; extern NSPersistentContainer *kPersistentContainer;
extern NSMutableDictionary<NSString *, AlbumArtwork *> *kArtworkDictionary; extern NSMutableDictionary<NSString *, AlbumArtwork *> *kArtworkDictionary;
static NSMutableDictionary *kMetadataCache = nil;
@implementation PlaylistEntry (Extension) @implementation PlaylistEntry (Extension)
+ (void)initialize {
if(!kMetadataCache) {
kMetadataCache = [[NSMutableDictionary alloc] init];
}
}
// The following read-only keys depend on the values of other properties // The following read-only keys depend on the values of other properties
+ (NSSet *)keyPathsForValuesAffectingUrl { + (NSSet *)keyPathsForValuesAffectingUrl {
@ -789,14 +781,6 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
} }
- (NSString *_Nullable)readAllValuesAsString:(NSString *_Nonnull)tagName { - (NSString *_Nullable)readAllValuesAsString:(NSString *_Nonnull)tagName {
NSMutableDictionary *dict = [kMetadataCache objectForKey:self.urlString];
if(dict) {
NSString *value = [dict objectForKey:tagName];
if(value) {
return value;
}
}
id metaObj = self.metadataBlob; id metaObj = self.metadataBlob;
if(metaObj && [metaObj isKindOfClass:[NSDictionary class]]) { if(metaObj && [metaObj isKindOfClass:[NSDictionary class]]) {
@ -805,13 +789,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
NSArray *values = [metaDict objectForKey:tagName]; NSArray *values = [metaDict objectForKey:tagName];
if(values) { if(values) {
NSString *value = [values componentsJoinedByString:@", "]; return [values componentsJoinedByString:@", "];
if(!dict) {
dict = [[NSMutableDictionary alloc] init];
[kMetadataCache setObject:dict forKey:self.urlString];
}
[dict setObject:value forKey:tagName];
return value;
} }
} }
@ -820,7 +798,6 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
- (void)deleteAllValues { - (void)deleteAllValues {
self.metadataBlob = nil; self.metadataBlob = nil;
[kMetadataCache removeObjectForKey:self.urlString];
} }
- (void)deleteValue:(NSString *_Nonnull)tagName { - (void)deleteValue:(NSString *_Nonnull)tagName {
@ -857,11 +834,6 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
} }
- (void)addValue:(NSString *_Nonnull)tagName fromString:(NSString *_Nonnull)value { - (void)addValue:(NSString *_Nonnull)tagName fromString:(NSString *_Nonnull)value {
NSMutableDictionary *dict = [kMetadataCache objectForKey:self.urlString];
if(dict) {
[dict removeObjectForKey:tagName];
}
id metaObj = self.metadataBlob; id metaObj = self.metadataBlob;
if(metaObj && [metaObj isKindOfClass:[NSDictionary class]]) { if(metaObj && [metaObj isKindOfClass:[NSDictionary class]]) {