Permalink
Browse files

Minor changes for maximum speed.

  • Loading branch information...
1 parent 17ef7be commit c53c1af0321e6aaa72e897a9d9ab3d77ad842122 @blach committed Jan 17, 2012
Showing with 38 additions and 23 deletions.
  1. +38 −23 Core/Source/DTLocalizableStringScanner.m
@@ -192,11 +192,12 @@ - (void)main
}
}
-#define IS_WHITESPACE(_c) ([[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:(_c)])
+
+#define IS_WHITESPACE(_c) (_c == ' ' || _c == '\t' || _c == 0xA || _c == 0xB || _c == 0xC || _c == 0xD || _c == 0x85)
- (void)_scanWhitespace
{
- while (IS_WHITESPACE(_characters[_currentIndex]) && _currentIndex < _stringLength)
+ while (IS_WHITESPACE(_characters[_currentIndex]) && _currentIndex < _charactersRange.length)
{
_currentIndex++;
}
@@ -305,7 +306,6 @@ - (NSString *)_scanParameter
}
- (BOOL)_processMacroAtRange:(NSRange)range
- NSMutableArray *parameters = [[NSMutableArray alloc] initWithCapacity:10];
{
if (_characters == nil) {
_charactersRange = NSMakeRange(range.location, [_charactersAsString length] - range.location);
@@ -314,6 +314,7 @@ - (BOOL)_processMacroAtRange:(NSRange)range
}
_currentIndex = range.location + range.length - _charactersRange.location;
+ NSMutableArray *parameters = [[NSMutableArray alloc] initWithCapacity:3];
// skip any whitespace between here and the (
[self _scanWhitespace];
@@ -366,29 +367,43 @@ - (BOOL)_processMacroAtRange:(NSRange)range
}
}
- NSArray *expectedParameters = [_validMacros objectForKey:macroName];
- if ([expectedParameters count] == [parameters count])
- {
- // hooray, we successfully scanned!
-
- DTLocalizableStringEntry *entry = [[DTLocalizableStringEntry alloc] init];
- for (NSUInteger i = 0; i < [parameters count]; ++i)
+ if ([parameters count] > 0) {
+ NSString *macroName = [_charactersAsString substringWithRange:range];
@blach
blach Jan 17, 2012 owner

Re-added missing line from commit e890ca8

+ NSArray *expectedParameters = [_validMacros objectForKey:macroName];
+ if ([expectedParameters count] == [parameters count])
{
- NSString *property = [expectedParameters objectAtIndex:i];
- NSString *value = [parameters objectAtIndex:i];
- [entry setValue:value forKey:property];
- }
-
- if (_entryFoundCallback)
+ // hooray, we successfully scanned!
+
+ DTLocalizableStringEntry *entry = [[DTLocalizableStringEntry alloc] init];
+ for (NSUInteger i = 0; i < [parameters count]; ++i)
+ {
+ NSString *property = [expectedParameters objectAtIndex:i];
+ NSString *value = [parameters objectAtIndex:i];
+
+ if ([property isEqualToString:@"rawKey"]) {
+ entry.rawKey = value;
+ } else if ([property isEqualToString:@"comment"]) {
+ [entry setComment:value];
+ } else if ([property isEqualToString:@"tableName"]) {
+ entry.tableName = value;
+ } else if ([property isEqualToString:@"bundle"]) {
+ entry.bundle = value;
+ } else {
+ [entry setValue:value forKey:property];
+ }
+ }
+
+ if (_entryFoundCallback)
+ {
+ _entryFoundCallback(entry);
+ }
+
+ return YES;
+ }
+ else
{
- _entryFoundCallback(entry);
+ NSLog(@"mismatch of parameters for %@ macro", macroName);
}
-
- return YES;
- }
- else
- {
- NSLog(@"mismatch of parameters for %@ macro", macroName);
}
return NO;

0 comments on commit c53c1af

Please sign in to comment.