From c1dadf3d62d39fa8b1d837b71a3831d4edb46e0a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 31 Jul 2014 08:07:32 -0300 Subject: [PATCH] Avoid creating an extra hash --- .../lib/active_support/hash_with_indifferent_access.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 30e27267a0..3d8f2d572b 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -246,11 +246,11 @@ def reject(*args, &block) # Convert to a regular hash with string keys. def to_hash - _new_hash = {} + _new_hash = Hash.new(default) each do |key, value| _new_hash[key] = convert_value(value, for: :to_hash) end - Hash.new(default).merge!(_new_hash) + _new_hash end protected -- GitLab