aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-04-03 15:13:34 +0200
committerJean Boussier <jean.boussier@gmail.com>2019-04-03 22:26:52 +0200
commited7234860b061b7b82672e6ba51c682254cd7eb7 (patch)
tree61cbe0739fa8698b48d00afdf6cf417a83cadbb3 /actionpack/lib/action_dispatch/routing/mapper.rb
parent9864f5e3d693b53c3540637c562a5be6e1e2c66a (diff)
downloadrails-ed7234860b061b7b82672e6ba51c682254cd7eb7.tar.gz
rails-ed7234860b061b7b82672e6ba51c682254cd7eb7.tar.bz2
rails-ed7234860b061b7b82672e6ba51c682254cd7eb7.zip
Deduplicate strings held by the router
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 74596fa1f0..f29f66990d 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -115,9 +115,9 @@ module ActionDispatch
@defaults = defaults
@set = set
- @to = to
- @default_controller = controller
- @default_action = default_action
+ @to = intern(to)
+ @default_controller = intern(controller)
+ @default_action = intern(default_action)
@ast = ast
@anchor = anchor
@via = via
@@ -222,6 +222,10 @@ module ActionDispatch
private :build_path
private
+ def intern(object)
+ object.is_a?(String) ? -object : object
+ end
+
def add_wildcard_options(options, formatted, path_ast)
# Add a constraint for wildcard route to make it non-greedy and match the
# optional format part of the route by default.