Skip to content
This repository
Browse code

#many? uses count instead of select - a bit faster

  • Loading branch information...
commit a23997329a6f66e088743c3844f6576f7bea9cac 1 parent 33f76e1
Julius Markūnas authored July 11, 2011 fxn committed July 11, 2011
2  activesupport/lib/active_support/core_ext/enumerable.rb
@@ -96,7 +96,7 @@ def index_by
96 96
   # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
97 97
   # 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.
98 98
   def many?(&block)
99  
-    size = block_given? ? select(&block).size : self.size
  99
+    size = block_given? ? count(&block) : self.size
100 100
     size > 1
101 101
   end
102 102
 

0 notes on commit a239973

Please sign in to comment.
Something went wrong with that request. Please try again.