Moved command char checker over to C call, believe it or not, this is alot faster then using a characterSet
This commit is contained in:
+1
-13
@@ -1017,17 +1017,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
static NSCharacterSet * _commandCharSet = nil;
|
||||
|
||||
+ (NSCharacterSet *)_commandCharSet
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_commandCharSet = [[NSCharacterSet characterSetWithCharactersInString:@"MmZzLlHhVvCcSsQqTtAa"] retain];
|
||||
});
|
||||
return _commandCharSet;
|
||||
}
|
||||
|
||||
#pragma mark Parser stuff!
|
||||
|
||||
- (void)_parsePathCommandData:(NSString *)command
|
||||
@@ -1039,7 +1028,6 @@ static NSCharacterSet * _commandCharSet = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
NSCharacterSet * set = [[self class] _commandCharSet];
|
||||
NSUInteger len = [command length];
|
||||
|
||||
// allocate memory for the string buffer for reading
|
||||
@@ -1061,7 +1049,7 @@ static NSCharacterSet * _commandCharSet = nil;
|
||||
unichar currentChar = buffer[i];
|
||||
unichar nextChar = buffer[i+1];
|
||||
BOOL atEnd = i == len-1;
|
||||
BOOL isStartCommand = [set characterIsMember:nextChar];
|
||||
BOOL isStartCommand = IJSVGIsLegalCommandCharacter(nextChar);
|
||||
if( ( currentBufferSize + 1 ) == currentSize ) {
|
||||
currentSize += defaultBufferSize;
|
||||
commandBuffer = (unichar *)realloc( commandBuffer, sizeof(unichar)*currentSize);
|
||||
|
||||
@@ -18,6 +18,7 @@ CGFloat angle( CGPoint a, CGPoint b );
|
||||
CGFloat radians_to_degrees( CGFloat radians);
|
||||
CGFloat degrees_to_radians( CGFloat degrees );
|
||||
|
||||
BOOL IJSVGIsLegalCommandCharacter(unichar aChar);
|
||||
+ (IJSVGCommandType)typeForCommandString:(NSString *)string;
|
||||
+ (CGFloat *)commandParameters:(NSString *)command
|
||||
count:(NSInteger *)count;
|
||||
|
||||
@@ -10,6 +10,18 @@
|
||||
|
||||
@implementation IJSVGUtils
|
||||
|
||||
BOOL IJSVGIsLegalCommandCharacter(unichar aChar)
|
||||
{
|
||||
char * validChars = "MmZzLlHhVvCcSsQqTtAa";
|
||||
NSUInteger length = strlen(validChars);
|
||||
for(NSUInteger i = 0; i < length; i++) {
|
||||
if(aChar == validChars[i]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
CGFloat angle( CGPoint a, CGPoint b ) {
|
||||
return [IJSVGUtils angleBetweenPointA:a
|
||||
pointb:b];
|
||||
|
||||
Reference in New Issue
Block a user