diff options
author | schneems <richard.schneeman@gmail.com> | 2015-07-27 01:45:29 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2015-07-30 12:31:05 -0500 |
commit | 4d2ccc119cac2dc2757d3d977059feba9db858d2 (patch) | |
tree | 49226f6313663278885ccea2cded15f8ca7f98d4 /actionpack/lib/action_dispatch/journey | |
parent | 005541b83eb6392bd53ad2e2a8b157c75cf81df1 (diff) | |
download | rails-4d2ccc119cac2dc2757d3d977059feba9db858d2.tar.gz rails-4d2ccc119cac2dc2757d3d977059feba9db858d2.tar.bz2 rails-4d2ccc119cac2dc2757d3d977059feba9db858d2.zip |
Remove array allocation
THe only reason we were allocating an array is to get the "missing_keys" variable in scope of the error message generator. Guess what? Arrays kinda take up a lot of memory, so by replacing that with a nil, we save:
35,303 bytes and 886 objects per request
Diffstat (limited to 'actionpack/lib/action_dispatch/journey')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/formatter.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index 95e1d2deb2..7b091a35ab 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -14,7 +14,7 @@ module ActionDispatch def generate(name, options, path_parameters, parameterize = nil) constraints = path_parameters.merge(options) - missing_keys = [] + missing_keys = nil # need for variable scope match_route(name, constraints) do |route| parameterized_parts = extract_parameterized_parts(route, options, path_parameters, parameterize) @@ -40,7 +40,7 @@ module ActionDispatch end message = "No route matches #{Hash[constraints.sort_by{|k,v| k.to_s}].inspect}" - message << " missing required keys: #{missing_keys.sort.inspect}" unless missing_keys.empty? + message << " missing required keys: #{missing_keys.sort.inspect}" if missing_keys && missing_keys.any? raise ActionController::UrlGenerationError, message end |