Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+load will slow startup speed, replace it with dispatch_once #677

Merged
merged 1 commit into from
Oct 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
+load will slow startup speed, replace it with dispatch_once
  • Loading branch information
chenxiaoping02 committed Jul 19, 2018
commit 035963eab61404ba1f3b1a37f9e86556b7dc1e9b
11 changes: 5 additions & 6 deletions lottie-ios/Classes/Extensions/UIColor+Expanded.m
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ + (UIColor *)LOT_colorWithHexString:(NSString *)stringToConvert {
// Lookup a color using css 3/svg color name
+ (UIColor *)LOT_colorWithName:(NSString *)cssColorName {
UIColor *color;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
colorNameCache = [[NSMutableDictionary alloc] init];
});

@synchronized(colorNameCache) {
// Look for the color in the cache
color = [colorNameCache objectForKey:cssColorName];
Expand Down Expand Up @@ -399,12 +404,6 @@ + (UIColor *)LOT_colorByLerpingFromColor:(UIColor *)fromColor toColor:(UIColor *
return [UIColor colorWithRed:r green:g blue:b alpha:a];
}

#pragma mark UIColor_Expanded initialization

+ (void)load {
colorNameCache = [[NSMutableDictionary alloc] init];
}

@end

#pragma mark -
Expand Down