Skip to content

Commit db53eca

Browse files
committed
Reorder conditions in HashWithIndifferentAccess#initialize
We should check the cheaper and more likely case first.
1 parent d4d07bc commit db53eca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

activesupport/lib/active_support/hash_with_indifferent_access.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def nested_under_indifferent_access
6868
end
6969

7070
def initialize(constructor = nil)
71-
if constructor.respond_to?(:to_hash)
71+
if constructor.nil?
72+
super()
73+
elsif constructor.respond_to?(:to_hash)
7274
super()
7375
update(constructor)
7476

7577
hash = constructor.is_a?(Hash) ? constructor : constructor.to_hash
7678
self.default = hash.default if hash.default
7779
self.default_proc = hash.default_proc if hash.default_proc
78-
elsif constructor.nil?
79-
super()
8080
else
8181
super(constructor)
8282
end

0 commit comments

Comments
 (0)