aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJulius Markūnas <julius.markunas@necolt.com>2011-07-11 14:59:51 +0300
committerJulius Markūnas <julius.markunas@necolt.com>2011-07-11 14:59:51 +0300
commitea0eb02f484f9220015aa62fd6435c0ae14cb710 (patch)
tree6af4d3c1a195227c695be5f97a8b97a0c970079b /activesupport
parente9f9ce971e17bcdc0cf74af926fdeacea56504a3 (diff)
downloadrails-ea0eb02f484f9220015aa62fd6435c0ae14cb710.tar.gz
rails-ea0eb02f484f9220015aa62fd6435c0ae14cb710.tar.bz2
rails-ea0eb02f484f9220015aa62fd6435c0ae14cb710.zip
#many? uses count instead of select - a bit faster
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index 6d7f771b5d..3e05c6eaf2 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -96,7 +96,7 @@ module Enumerable
# Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
# Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than 1 person is over 26.
def many?(&block)
- size = block_given? ? select(&block).size : self.size
+ size = block_given? ? count(&block) : self.size
size > 1
end