@@ -233,10 +233,6 @@ - (instancetype)initWithFormat:(FICImageFormat *)imageFormat imageCache:(FICImag
233233 return self;
234234}
235235
236- - (instancetype )init {
237- return [self initWithFormat: nil imageCache: nil ];
238- }
239-
240236- (void )dealloc {
241237 if (_fileDescriptor >= 0 ) {
242238 close (_fileDescriptor);
@@ -685,43 +681,47 @@ - (NSNumber *)_numberForEntryAtIndex:(NSInteger)index {
685681#pragma mark - Working with Metadata
686682
687683- (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 ];
695692
696- __block int32_t metadataVersion = OSAtomicIncrement32 (&_metadataVersion);
693+ __block int32_t metadataVersion = OSAtomicIncrement32 (&_metadataVersion);
697694
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+ }
711708
712- NSData *data = [NSJSONSerialization dataWithJSONObject: metadataDictionary options: kNilOptions error: NULL ];
709+ @autoreleasepool {
710+ NSData *data = [NSJSONSerialization dataWithJSONObject: metadataDictionary options: kNilOptions error: NULL ];
713711
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+ }
718716
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+ }
725725}
726726
727727- (void )_loadMetadata {
0 commit comments