Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Parser Performance Collection #9348
So I tried to work on performance in the parser. I did not have any ground breaking success but found some small and minor stuff here and there.
Some of the changes might be debatable. If something feels weird to any of you feel free to mention and I can remove it.
The most impactful change here (depending on the tested source of course) is the removal of flow code from the regular parser. (Only if not using the flow plugin)
The other big improvement is compiling the parser for node 6.9 or newer only. I was surprised to see it was using all transforms. This might be a problem if someone is using the parser in an older browser without first compiling.
Overall it is a tiny bit noticeable but most changes also add to readability and understanding the code.
The changes are separated into commits to make it easier to see what belongs together.
I also tried other things like exchanging the big switch-case for an object as hashmap, but that made no difference.
I also updated the benchmark tool to work better and more consistently. babel/parser_performance@1df708c
This saves some steps, as the regex parser does not have to backtrack for character classes, but is has to for alternates