Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove extra ast pass for Pattern#names
Before this commit #ast and #names were each doing a separate pass over the journey ast. Since both of these methods are called for every route definition, we can do that work up front in #initialize, consolidating into a single pass through the ast. I think we can also get rid of the `spec` alias, but I am planning to do that in a separate PR to limit the scope of this one. This is similar to the work done in rails#38901 and rails#39903, and the benchmark results are similar: ``` Warming up -------------------------------------- before 7.791k i/100ms after 15.843k i/100ms Calculating ------------------------------------- before 78.081k (± 1.4%) i/s - 397.341k in 5.089797s after 159.093k (± 1.8%) i/s - 807.993k in 5.080367s Comparison: after: 159093.1 i/s before: 78081.2 i/s - 2.04x (± 0.00) slower MEMORY Calculating ------------------------------------- before 240.000 memsize ( 40.000 retained) 4.000 objects ( 1.000 retained) 0.000 strings ( 0.000 retained) after 120.000 memsize ( 40.000 retained) 2.000 objects ( 1.000 retained) 0.000 strings ( 0.000 retained) Comparison: after: 120 allocated before: 240 allocated - 2.00x more ```
- Loading branch information