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

Change implementation to do it without asking each time for block_given?

Signed-off-by: Xavier Noria <fxn@hashref.com>
This commit is contained in:
Santiago Pastorino 2010-06-13 02:12:12 -03:00 committed by Xavier Noria
parent 36143d26cb
commit 6d19a4a664

View file

@ -130,12 +130,10 @@ module ActiveSupport
end
def merge!(other_hash)
other_hash.each do |k, v|
if block_given? && key?(k)
self[k] = yield k, self[k], v
else
self[k] = v
end
if block_given?
other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
else
other_hash.each { |k, v| self[k] = v }
end
self
end