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:
iska
2015-04-11 22:12:51 +02:00
parent 936c76d142
commit 4158ef0237
2 changed files with 11 additions and 11 deletions
+1 -5
View File
@@ -26,11 +26,7 @@
[self measureBlock:^{
HTMLTokenizer *tokenizer = [[HTMLTokenizer alloc] initWithString:string];
id token = nil;
do {
token = [tokenizer nextObject];
} while (token != nil);
[tokenizer allObjects];
}];
}