From 6d19a4a664914e908e75cfe90a0507cc9f53d1cd Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 13 Jun 2010 02:12:12 -0300 Subject: Change implementation to do it without asking each time for block_given? Signed-off-by: Xavier Noria --- activesupport/lib/active_support/ordered_hash.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'activesupport/lib/active_support/ordered_hash.rb') 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 -- cgit v1.2.3