aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-25 14:25:50 -0400
committerGitHub <noreply@github.com>2019-07-25 14:25:50 -0400
commit706ee3eb490781387e9a7e00ab9cfdb3d3dbf264 (patch)
tree8b489bde903ad8136132e45ffe993b4953ab01ef
parent8ff7efef6c102c6668c7f29e839af7da6663f7c6 (diff)
parent93188101424d8f92b25c4bf5e6518d475cccf4e4 (diff)
downloadrails-706ee3eb490781387e9a7e00ab9cfdb3d3dbf264.tar.gz
rails-706ee3eb490781387e9a7e00ab9cfdb3d3dbf264.tar.bz2
rails-706ee3eb490781387e9a7e00ab9cfdb3d3dbf264.zip
Merge pull request #36758 from jturkel/feature/hash-optimization
Avoid unnecessary hash allocation in HashWithIndifferentAccess#convert_value
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index 5981763f0e..bbb7c36382 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -367,7 +367,9 @@ module ActiveSupport
key.kind_of?(Symbol) ? key.to_s : key
end
- def convert_value(value, options = {}) # :doc:
+ EMPTY_HASH = {}.freeze
+
+ def convert_value(value, options = EMPTY_HASH) # :doc:
if value.is_a? Hash
if options[:for] == :to_hash
value.to_hash