From f6bedc960dfbd2a5262d65c69fb51789b060643e Mon Sep 17 00:00:00 2001 From: Grant Hutchins Date: Wed, 27 Jun 2012 20:09:30 -0400 Subject: [PATCH] Speed up Hash#transform_keys using Hash#each_key See https://gist.github.com/3007749 for justification --- activesupport/lib/active_support/core_ext/hash/keys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/core_ext/hash/keys.rb b/activesupport/lib/active_support/core_ext/hash/keys.rb index 8e728691c675..e753e36124c4 100644 --- a/activesupport/lib/active_support/core_ext/hash/keys.rb +++ b/activesupport/lib/active_support/core_ext/hash/keys.rb @@ -7,7 +7,7 @@ class Hash # # => { "NAME" => "Rob", "AGE" => "28" } def transform_keys result = {} - keys.each do |key| + each_key do |key| result[yield(key)] = self[key] end result