mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[AS*ImageNode] dispatch to the background before scheduling image download request (perf).
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#import "ASLog.h"
|
||||
#import "ASPhotosFrameworkImageRequest.h"
|
||||
#import "ASEqualityHelpers.h"
|
||||
#import "ASInternalHelpers.h"
|
||||
|
||||
#if !AS_IOS8_SDK_OR_LATER
|
||||
#error ASMultiplexImageNode can be used on iOS 7, but must be linked against the iOS 8 SDK.
|
||||
@@ -751,6 +752,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
}
|
||||
|
||||
// Download!
|
||||
ASPerformBlockOnBackgroundThread(^{
|
||||
if (_downloaderSupportsNewProtocol) {
|
||||
[self _setDownloadIdentifier:[_downloader downloadImageWithURL:imageURL
|
||||
callbackQueue:dispatch_get_main_queue()
|
||||
@@ -791,6 +793,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
[strongSelf->_delegate multiplexImageNode:weakSelf didFinishDownloadingImageWithIdentifier:imageIdentifier error:error];
|
||||
}]];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#import "ASDisplayNode+FrameworkPrivate.h"
|
||||
#import "ASEqualityHelpers.h"
|
||||
#import "ASThread.h"
|
||||
#import "ASInternalHelpers.h"
|
||||
|
||||
#if PIN_REMOTE_IMAGE
|
||||
#import "ASPINRemoteImageDownloader.h"
|
||||
@@ -263,6 +264,8 @@
|
||||
|
||||
- (void)_downloadImageWithCompletion:(void (^)(UIImage *image, NSError*, id downloadIdentifier))finished
|
||||
{
|
||||
ASPerformBlockOnBackgroundThread(^{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
if (_downloaderSupportsNewProtocol) {
|
||||
_downloadIdentifier = [_downloader downloadImageWithURL:_URL
|
||||
callbackQueue:dispatch_get_main_queue()
|
||||
@@ -282,6 +285,7 @@
|
||||
}
|
||||
}];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_lazilyLoadImageIfNecessary
|
||||
|
||||
Reference in New Issue
Block a user