Skip to content

Commit

Permalink
Merge pull request airbnb#677 from chenxiaoping1/replaceLoadWithOnce
Browse files Browse the repository at this point in the history
+load will slow startup speed, replace it with dispatch_once
  • Loading branch information
buba447 committed Oct 4, 2018
2 parents 4a5bc1f + 56d6acd commit 35aa494
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit 35aa494

Please sign in to comment.