Merge pull request #40721 from d12/optimize_hash_with_indifferent_access_initializer
55% speedup for HashWithIndifferentAccess.new when no args provided
This commit is contained in:
commit
366df0397f
|
@ -64,7 +64,7 @@ module ActiveSupport
|
|||
self
|
||||
end
|
||||
|
||||
def initialize(constructor = {})
|
||||
def initialize(constructor = nil)
|
||||
if constructor.respond_to?(:to_hash)
|
||||
super()
|
||||
update(constructor)
|
||||
|
@ -72,6 +72,8 @@ module ActiveSupport
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue