Skip to content
Browse files

Speed up Hash#transform_keys using Hash#each_key

See https://gist.github.com/3007749 for justification
  • Loading branch information...
1 parent 692b64e commit f6bedc960dfbd2a5262d65c69fb51789b060643e @nertzy nertzy committed Jun 27, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/core_ext/hash/keys.rb
View
2 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

0 comments on commit f6bedc9

Please sign in to comment.
Something went wrong with that request. Please try again.