Generic Freelist Allocator for Go
pkg.go.dev
pkg.go.dev
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
If you can use this approach for the entire parser I imagine the gains would be much more significant
Correction: no, looks like I do indeed call it each time. Well, it's still more efficient I guess :))