diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-06-13 02:12:12 -0300 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-06-13 07:27:26 +0200 |
commit | 6d19a4a664914e908e75cfe90a0507cc9f53d1cd (patch) | |
tree | 39f3db112fd94aa421fa6d794b8f91d83eef8ef4 /activesupport/lib | |
parent | 36143d26cb841210b5f22aff4ed9c093a0554a1a (diff) | |
download | rails-6d19a4a664914e908e75cfe90a0507cc9f53d1cd.tar.gz rails-6d19a4a664914e908e75cfe90a0507cc9f53d1cd.tar.bz2 rails-6d19a4a664914e908e75cfe90a0507cc9f53d1cd.zip |
Change implementation to do it without asking each time for block_given?
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/ordered_hash.rb | 10 |
1 files changed, 4 insertions, 6 deletions
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 |