Skip to content

Commit 15ab722

Browse files
committed
Avoid creating an extra Hash object when no options were given
1 parent 055f71c commit 15ab722

File tree

1 file changed

+7
-5
lines changed
  • actionpack/lib/action_controller/metal

1 file changed

+7
-5
lines changed

actionpack/lib/action_controller/metal/head.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ module Head
1818
# render
1919
#
2020
# See Rack::Utils::SYMBOL_TO_STATUS_CODE for a full list of valid +status+ symbols.
21-
def head(status, options = {})
21+
def head(status, options = nil)
2222
if status.is_a?(Hash)
2323
raise ArgumentError, "#{status.inspect} is not a valid value for `status`."
2424
end
2525

2626
status ||= :ok
2727

28-
location = options.delete(:location)
29-
content_type = options.delete(:content_type)
28+
if options
29+
location = options.delete(:location)
30+
content_type = options.delete(:content_type)
3031

31-
options.each do |key, value|
32-
headers[key.to_s.split(/[-_]/).each { |v| v[0] = v[0].upcase }.join("-")] = value.to_s
32+
options.each do |key, value|
33+
headers[key.to_s.split(/[-_]/).each { |v| v[0] = v[0].upcase }.join("-")] = value.to_s
34+
end
3335
end
3436

3537
self.status = status

0 commit comments

Comments
 (0)