Fixes possible issues with wrong initial capacities

This commit is contained in:
michael starke
2014-07-31 13:08:28 +02:00
parent d7741451fd
commit 95bb918b6f
3 changed files with 3 additions and 3 deletions

View File

@@ -96,7 +96,7 @@
if(![context isValid]) {
return nil;
}
NSUInteger reserverd = [context.normalizedCommand length] / 4;
NSUInteger reserverd = MAX(1,[context.normalizedCommand length] / 4);
NSMutableArray *commands = [[NSMutableArray alloc] initWithCapacity:reserverd];
NSMutableArray __block *commandRanges = [[NSMutableArray alloc] initWithCapacity:reserverd];
NSRegularExpression *commandRegExp = [[NSRegularExpression alloc] initWithPattern:@"\\{[^\\}]+\\}" options:NSRegularExpressionCaseInsensitive error:0];