Remove redundant queue switch from RCTLocalAssetImageLoader

Summary:
Switching queues in `RCTLocalAssetImageLoader` is unnecessary. We dispatch to main queue before assigning the image to `UIImageView`.

Changelog: Remove redundant queue switch from RCTLocalAssetImageLoader

Reviewed By: PeteTheHeat

Differential Revision: D20347223

fbshipit-source-id: ff6215838f0462356d4a516e6ec31c82a742881a
This commit is contained in:
Samuel Susla 2020-03-11 13:57:52 -07:00 коммит произвёл Facebook GitHub Bot
Родитель f3a53fd338
Коммит 3198009410
1 изменённых файлов: 12 добавлений и 21 удалений

Просмотреть файл

@ -49,28 +49,19 @@ RCT_EXPORT_MODULE()
partialLoadHandler:(RCTImageLoaderPartialLoadBlock)partialLoadHandler
completionHandler:(RCTImageLoaderCompletionBlock)completionHandler
{
__block auto cancelled = std::make_shared<std::atomic<bool>>(false);
RCTExecuteOnMainQueue(^{
if (cancelled->load()) {
return;
UIImage *image = RCTImageFromLocalAssetURL(imageURL);
if (image) {
if (progressHandler) {
progressHandler(1, 1);
}
UIImage *image = RCTImageFromLocalAssetURL(imageURL);
if (image) {
if (progressHandler) {
progressHandler(1, 1);
}
completionHandler(nil, image);
} else {
NSString *message = [NSString stringWithFormat:@"Could not find image %@", imageURL];
RCTLogWarn(@"%@", message);
completionHandler(RCTErrorWithMessage(message), nil);
}
});
return ^{
cancelled->store(true);
};
completionHandler(nil, image);
} else {
NSString *message = [NSString stringWithFormat:@"Could not find image %@", imageURL];
RCTLogWarn(@"%@", message);
completionHandler(RCTErrorWithMessage(message), nil);
}
return nil;
}
@end