aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/path
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2017-01-11 14:50:42 +0100
committerJean Boussier <jean.boussier@gmail.com>2017-01-18 11:10:52 +0100
commit5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0 (patch)
tree7244c68a0ba7239a3893933a16ddb069ba04a170 /actionpack/lib/action_dispatch/journey/path
parent299728de1da404d789752156a13828ec3b48f3d6 (diff)
downloadrails-5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0.tar.gz
rails-5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0.tar.bz2
rails-5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0.zip
Fully initialize routes before the first request is handled
`AD::Journey::GTG::Simulator` is lazily built the first time `Journey::Router#find_routes` is invoked, which happens when the first request is served. On large applications with many routes, building the simulator can take several hundred milliseconds (~700ms for us). Triggering this initialization during the boot process reduces the impact of deploys on the application response time.
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/path')
-rw-r--r--actionpack/lib/action_dispatch/journey/path/pattern.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/journey/path/pattern.rb b/actionpack/lib/action_dispatch/journey/path/pattern.rb
index 0902b9233e..cf0108ec32 100644
--- a/actionpack/lib/action_dispatch/journey/path/pattern.rb
+++ b/actionpack/lib/action_dispatch/journey/path/pattern.rb
@@ -31,6 +31,13 @@ module ActionDispatch
Visitors::FormatBuilder.new.accept(spec)
end
+ def eager_load!
+ required_names
+ offsets
+ to_regexp
+ nil
+ end
+
def ast
@spec.find_all(&:symbol?).each do |node|
re = @requirements[node.to_sym]