This repository has been archived by the owner on Sep 13, 2017. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been working on reducing my app's boot time, and found that a lot of time was being spent in
Module#===
, which was primarily the fault ofJourney::GTG::Builder
's case statements.Module#===
has to walk the inheritance tree for a class when doing comparisons, so we can achieve better performance by avoiding it.I refactored
Builder
so that rather than usingnullable?
,firstpos
, andlastpos
methods, those methods are now implemented on the individual nodes. This has the added benefit of being far more Rubyish. :)Additionally, I implemented memoizations on the
Terminal
andCat
nodes, which improved the runtimes of their methods which return arrays by an order of magnitude according to ruby-prof.The overall effect is that
ActionDispatch::Routing::Mapper::Resources#resources
' runtime is reduced from 968ms to 888ms in my app - about a 9% performance gain. Not blowing any hair back, but every little bit helps, and IMO it improves the code quality, as well. The performance gain should be more notable as the Journey AST increases in size.I applied this against the 1-0-stable branch, but it also applies against and passes tests on master, as well