Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Use static regular expression instance for transform parsing. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wqyfavor authored and jianhan-he committed Jun 18, 2019
1 parent 07151c3 commit a43c768
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ios/sdk/WeexSDK/Sources/Component/WXTransform.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,16 @@ - (void)parseTransform:(NSString *)cssValue
return;
}

NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\w+)\\((.+?)\\)"
options:NSRegularExpressionCaseInsensitive
error:&error];
static NSRegularExpression* parseRegex = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSError *error = NULL;
parseRegex = [NSRegularExpression regularExpressionWithPattern:@"(\\w+)\\((.+?)\\)"
options:NSRegularExpressionCaseInsensitive
error:&error];
});

NSArray *matches = [regex matchesInString:cssValue options:0 range:NSMakeRange(0, cssValue.length)];
NSArray *matches = [parseRegex matchesInString:cssValue options:0 range:NSMakeRange(0, cssValue.length)];

for (NSTextCheckingResult *match in matches) {
NSString *name = [cssValue substringWithRange:[match rangeAtIndex:1]];
Expand Down

0 comments on commit a43c768

Please sign in to comment.