Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
/ sockit Public archive
forked from NimbusKit/sockit

Commit

Permalink
Cache nonParameterCharacterSet in SOCKit.m to avoid memory spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Suvorov committed Jul 7, 2015
1 parent 90937fd commit 332441c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/SOCKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ - (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;
if (staticNonParameterCharacterSet == nil) {
NSMutableCharacterSet* parameterCharacterSet = [NSMutableCharacterSet alphanumericCharacterSet];
[parameterCharacterSet addCharactersInString:@".@_"];
staticNonParameterCharacterSet = [parameterCharacterSet invertedSet];
}
return staticNonParameterCharacterSet;
}

- (void)_compilePattern {
Expand Down

0 comments on commit 332441c

Please sign in to comment.