diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index cd450fd00f..02980d7473 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -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