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:
Rafael França 2020-12-01 14:56:56 -05:00 committed by GitHub
commit 366df0397f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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