diff --git a/src/SOCKit.m b/src/SOCKit.m index 2cd36d8..0c7bafb 100644 --- a/src/SOCKit.m +++ b/src/SOCKit.m @@ -71,10 +71,15 @@ - (id)copyWithZone:(NSZone *)zone { #pragma mark - Pattern Compilation - (NSCharacterSet *)nonParameterCharacterSet { - NSMutableCharacterSet* parameterCharacterSet = [NSMutableCharacterSet alphanumericCharacterSet]; - [parameterCharacterSet addCharactersInString:@".@_"]; - NSCharacterSet* nonParameterCharacterSet = [parameterCharacterSet invertedSet]; - return nonParameterCharacterSet; + static NSCharacterSet* staticNonParameterCharacterSet = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSMutableCharacterSet* parameterCharacterSet = [NSMutableCharacterSet alphanumericCharacterSet]; + [parameterCharacterSet addCharactersInString:@".@_"]; + staticNonParameterCharacterSet = [parameterCharacterSet invertedSet]; + }); + + return staticNonParameterCharacterSet; } - (void)_compilePattern {