Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Speed up Hash#transform_keys using Hash#each_key

See https://gist.github.com/3007749 for justification
  • Loading branch information...
commit f6bedc960dfbd2a5262d65c69fb51789b060643e 1 parent 692b64e
@nertzy nertzy authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.