1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Speed up Hash#transform_keys using Hash#each_key

See https://gist.github.com/3007749 for justification
This commit is contained in:
Grant Hutchins 2012-06-27 20:09:30 -04:00
parent 692b64e3ac
commit f6bedc960d

View file

@ -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