I've used this idea to speed up AST parsing: <a href="https://github.com/z7zmey/php-parser/issues/21">https://github.com/z7zmey/php-parser/issues/21</a><p>By just reducing cost of doing allocations (but still allocating the same number of structs) on some of the hot paths it sped up making of the AST tree by 1.5x<p>If you can use this approach for the entire parser I imagine the gains would be much more significant