Skip to content

Commit

Permalink
Optimize HashWithIndifferentAccess.new when no args are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Woodthorpe committed Dec 1, 2020
1 parent 835dba2 commit 0841cdf
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -64,14 +64,16 @@ def nested_under_indifferent_access
self
end

def initialize(constructor = {})
def initialize(constructor = nil)
if constructor.respond_to?(:to_hash)
super()
update(constructor)

hash = constructor.is_a?(Hash) ? constructor : constructor.to_hash
self.default = hash.default if hash.default
self.default_proc = hash.default_proc if hash.default_proc
elsif constructor.nil?
super()
else
super(constructor)
end
Expand Down

0 comments on commit 0841cdf

Please sign in to comment.