Use a accumulator-character-token in the tokenizer to reduce the initialization overhead
Initializing character tokens, and the NSString objects they use, results in a relatively high overhead. The tokenizer now accumulated all successive characters in on accumulator token until a non-character token is emitted. This change reduces the execution time of the performance test on the local machine by 48% (reference to baseline)
This commit is contained in:
@@ -26,11 +26,7 @@
|
||||
|
||||
[self measureBlock:^{
|
||||
HTMLTokenizer *tokenizer = [[HTMLTokenizer alloc] initWithString:string];
|
||||
|
||||
id token = nil;
|
||||
do {
|
||||
token = [tokenizer nextObject];
|
||||
} while (token != nil);
|
||||
[tokenizer allObjects];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user