Optimize performance
Optimize performance

Parsing large files was very slow. Two optimizations were made:
* Stop copying the input string in Tokenizer.tokenize()
  The string slicing caused copying of the whole input string on every
  token. Now, weexplicitly track our position in the string and pass that
  to the regex functions, leaving the string untouched.
  This was the big one and sped up execution by a factor of 5.4.
* Optimize the order in which the parser checks tokens if multiple token
  types are possible. This gave an additional speedup of 12%.

Overall, the parsing time of a 1MB file went from 91 to 15 seconds. More
optimizations would definitely be possible, but they are less obvious than
the string copying issue.

Grk0/python-libconf