Skip to content

Commit

Permalink
Merge pull request rails#21075 from byroot/not-empty-vs-any
Browse files Browse the repository at this point in the history
Array#any? is slower and not the inverse of Array#empty?
  • Loading branch information
rafaelfranca committed Jul 30, 2015
2 parents 5373bf2 + 32133db commit f8e81d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/journey/formatter.rb
Expand Up @@ -25,7 +25,7 @@ def generate(name, options, path_parameters, parameterize = nil)
next unless name || route.dispatcher?

missing_keys = missing_keys(route, parameterized_parts)
next if missing_keys && missing_keys.any?
next if missing_keys && !missing_keys.empty?
params = options.dup.delete_if do |key, _|
parameterized_parts.key?(key) || route.defaults.key?(key)
end
Expand All @@ -40,7 +40,7 @@ def generate(name, options, path_parameters, parameterize = nil)
end

message = "No route matches #{Hash[constraints.sort_by{|k,v| k.to_s}].inspect}"
message << " missing required keys: #{missing_keys.sort.inspect}" if missing_keys && missing_keys.any?
message << " missing required keys: #{missing_keys.sort.inspect}" if missing_keys && !missing_keys.empty?

raise ActionController::UrlGenerationError, message
end
Expand Down

0 comments on commit f8e81d4

Please sign in to comment.