提交 f8e81d41 编写于 作者: R Rafael Mendonça França

Merge pull request #21075 from byroot/not-empty-vs-any

Array#any? is slower and not the inverse of Array#empty?
......@@ -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
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册