Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

Signed-off-by: Xavier Noria <fxn@hashref.com>
  • Loading branch information...
commit 6d19a4a664914e908e75cfe90a0507cc9f53d1cd 1 parent 36143d2
@spastorino spastorino authored fxn committed
Showing with 4 additions and 6 deletions.
  1. +4 −6 activesupport/lib/active_support/ordered_hash.rb
View
10 activesupport/lib/active_support/ordered_hash.rb
@@ -130,12 +130,10 @@ def shift
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
Please sign in to comment.
Something went wrong with that request. Please try again.