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:
parent
36143d26cb
commit
6d19a4a664
1 changed files with 4 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue