@@ -233,10 +233,6 @@ - (instancetype)initWithFormat:(FICImageFormat *)imageFormat imageCache:(FICImag
233
233
return self;
234
234
}
235
235
236
- - (instancetype )init {
237
- return [self initWithFormat: nil imageCache: nil ];
238
- }
239
-
240
236
- (void )dealloc {
241
237
if (_fileDescriptor >= 0 ) {
242
238
close (_fileDescriptor);
@@ -685,43 +681,47 @@ - (NSNumber *)_numberForEntryAtIndex:(NSInteger)index {
685
681
#pragma mark - Working with Metadata
686
682
687
683
- (void )saveMetadata {
688
- [_lock lock ];
689
-
690
- NSDictionary *metadataDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
691
- [_indexMap copy ], FICImageTableIndexMapKey,
692
- [_sourceImageMap copy ], FICImageTableContextMapKey,
693
- [[_MRUEntries array ] copy ], FICImageTableMRUArrayKey,
694
- [_imageFormatDictionary copy ], FICImageTableFormatKey, nil ];
684
+ @autoreleasepool {
685
+ [_lock lock ];
686
+
687
+ NSDictionary *metadataDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
688
+ [_indexMap copy ], FICImageTableIndexMapKey,
689
+ [_sourceImageMap copy ], FICImageTableContextMapKey,
690
+ [[_MRUEntries array ] copy ], FICImageTableMRUArrayKey,
691
+ [_imageFormatDictionary copy ], FICImageTableFormatKey, nil ];
695
692
696
- __block int32_t metadataVersion = OSAtomicIncrement32 (&_metadataVersion);
693
+ __block int32_t metadataVersion = OSAtomicIncrement32 (&_metadataVersion);
697
694
698
- [_lock unlock ];
699
-
700
- static dispatch_queue_t __metadataQueue = nil ;
701
- static dispatch_once_t onceToken;
702
- dispatch_once (&onceToken, ^{
703
- __metadataQueue = dispatch_queue_create (" com.path.FastImageCache.ImageTableMetadataQueue" , NULL );
704
- });
705
-
706
- dispatch_async (__metadataQueue, ^{
707
- // Cancel serialization if a new metadata version is queued to be saved
708
- if (metadataVersion != _metadataVersion) {
709
- return ;
710
- }
695
+ [_lock unlock ];
696
+
697
+ static dispatch_queue_t __metadataQueue = nil ;
698
+ static dispatch_once_t onceToken;
699
+ dispatch_once (&onceToken, ^{
700
+ __metadataQueue = dispatch_queue_create (" com.path.FastImageCache.ImageTableMetadataQueue" , NULL );
701
+ });
702
+
703
+ dispatch_async (__metadataQueue, ^{
704
+ // Cancel serialization if a new metadata version is queued to be saved
705
+ if (metadataVersion != _metadataVersion) {
706
+ return ;
707
+ }
711
708
712
- NSData *data = [NSJSONSerialization dataWithJSONObject: metadataDictionary options: kNilOptions error: NULL ];
709
+ @autoreleasepool {
710
+ NSData *data = [NSJSONSerialization dataWithJSONObject: metadataDictionary options: kNilOptions error: NULL ];
713
711
714
- // Cancel disk writing if a new metadata version is queued to be saved
715
- if (metadataVersion != _metadataVersion) {
716
- return ;
717
- }
712
+ // Cancel disk writing if a new metadata version is queued to be saved
713
+ if (metadataVersion != _metadataVersion) {
714
+ return ;
715
+ }
718
716
719
- BOOL fileWriteResult = [data writeToFile: [self metadataFilePath ] atomically: NO ];
720
- if (fileWriteResult == NO ) {
721
- NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s couldn't write metadata for format %@ " , __PRETTY_FUNCTION__, [_imageFormat name ]];
722
- [self .imageCache _logMessage: message];
723
- }
724
- });
717
+ BOOL fileWriteResult = [data writeToFile: [self metadataFilePath ] atomically: NO ];
718
+ if (fileWriteResult == NO ) {
719
+ NSString *message = [NSString stringWithFormat: @" *** FIC Error: %s couldn't write metadata for format %@ " , __PRETTY_FUNCTION__, [_imageFormat name ]];
720
+ [self .imageCache _logMessage: message];
721
+ }
722
+ }
723
+ });
724
+ }
725
725
}
726
726
727
727
- (void )_loadMetadata {
0 commit comments