From f061ffd9f4e7f7d612d4baa25e8075bb23896275 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Sat, 23 Jul 2011 15:41:55 -0400 Subject: [PATCH] Trivial optimization for Enumerable#each_with_object --- activesupport/lib/active_support/core_ext/enumerable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index f2dd34cc55..ddb4f3012f 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -76,10 +76,10 @@ def sum(identity = 0, &block) # # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1 # - def each_with_object(memo, &block) + def each_with_object(memo) return to_enum :each_with_object, memo unless block_given? each do |element| - block.call(element, memo) + yield element, memo end memo end unless [].respond_to?(:each_with_object) -- GitLab