Skip to content

Commit f918cd5

Browse files
author
Mallory Paine
committed
Remove unnecessary inner dictionary from requests dictionary
1 parent 209ec52 commit f918cd5

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

FastImageCache/FICImageCache.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
static NSString *const FICImageCacheFormatKey = @"FICImageCacheFormatKey";
1919
static NSString *const FICImageCacheCompletionBlocksKey = @"FICImageCacheCompletionBlocksKey";
20-
static NSString *const FICImageCacheEntitiesKey = @"FICImageCacheEntitiesKey";
2120
static NSString *const FICImageCacheEntityKey = @"FICImageCacheEntityKey";
2221

2322
#pragma mark - Class Extension
@@ -192,18 +191,16 @@ - (BOOL)_retrieveImageForEntity:(id <FICEntity>)entity withFormatName:(NSString
192191
NSMutableDictionary *requestDictionary = [_requests objectForKey:sourceImageURL];
193192
if (requestDictionary == nil) {
194193
// If we're here, then we aren't currently fetching this image.
195-
NSMutableDictionary *entityRequestsDictionary = [NSMutableDictionary dictionary];
196-
requestDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: entityRequestsDictionary, FICImageCacheEntitiesKey, nil];
194+
NSMutableDictionary *requestDictionary = [NSMutableDictionary dictionary];
197195
[_requests setObject:requestDictionary forKey:sourceImageURL];
198196

199-
_FICAddCompletionBlockForEntity(formatName, entityRequestsDictionary, entity, completionBlock);
197+
_FICAddCompletionBlockForEntity(formatName, requestDictionary, entity, completionBlock);
200198
[_delegate imageCache:self wantsSourceImageForEntity:entity withFormatName:formatName completionBlock:^(UIImage *sourceImage) {
201199
[self _imageDidLoad:sourceImage forURL:sourceImageURL];
202200
}];
203201
} else {
204202
// We have an existing request dictionary, which means this URL is currently being fetched.
205-
NSMutableDictionary *entityRequestsDictionary = [requestDictionary objectForKey:FICImageCacheEntitiesKey];
206-
_FICAddCompletionBlockForEntity(formatName, entityRequestsDictionary, entity, completionBlock);
203+
_FICAddCompletionBlockForEntity(formatName, requestDictionary, entity, completionBlock);
207204
}
208205
} else {
209206
NSString *message = [NSString stringWithFormat:@"*** FIC Error: %s entity %@ returned a nil source image URL for image format %@.", __PRETTY_FUNCTION__, entity, formatName];
@@ -222,8 +219,7 @@ - (BOOL)_retrieveImageForEntity:(id <FICEntity>)entity withFormatName:(NSString
222219
- (void)_imageDidLoad:(UIImage *)image forURL:(NSURL *)URL {
223220
NSDictionary *requestDictionary = [_requests objectForKey:URL];
224221
if (image != nil && requestDictionary != nil) {
225-
NSMutableDictionary *entityRequestsDictionary = [requestDictionary objectForKey:FICImageCacheEntitiesKey];
226-
for (NSMutableDictionary *entityDictionary in [entityRequestsDictionary allValues]) {
222+
for (NSMutableDictionary *entityDictionary in [requestDictionary allValues]) {
227223
id <FICEntity> entity = [entityDictionary objectForKey:FICImageCacheEntityKey];
228224
NSString *formatName = [entityDictionary objectForKey:FICImageCacheFormatKey];
229225
NSDictionary *completionBlocksDictionary = [entityDictionary objectForKey:FICImageCacheCompletionBlocksKey];

0 commit comments

Comments
 (0)