Skip to content

Commit

Permalink
Reduce startup time. (#1293)
Browse files Browse the repository at this point in the history
Move file level static into a function so that it isn't being initialized pre-main.
  • Loading branch information
dmaclach authored and nguyenhuy committed Jan 17, 2019
1 parent 45f2347 commit 0a48cd7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Source/Details/ASBasicImageDownloader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,18 @@ @interface NSURLRequest (ASBasicImageDownloader)
@end

@implementation NSURLRequest (ASBasicImageDownloader)
static const char *kContextKey = NSStringFromClass(ASBasicImageDownloaderContext.class).UTF8String;

static const void *ContextKey() {
return @selector(asyncdisplaykit_context);
}

- (void)setAsyncdisplaykit_context:(ASBasicImageDownloaderContext *)asyncdisplaykit_context
{
objc_setAssociatedObject(self, kContextKey, asyncdisplaykit_context, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject(self, ContextKey(), asyncdisplaykit_context, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (ASBasicImageDownloader *)asyncdisplaykit_context
{
return objc_getAssociatedObject(self, kContextKey);
return objc_getAssociatedObject(self, ContextKey());
}
@end

Expand Down

0 comments on commit 0a48cd7

Please sign in to comment.