Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #241 from Ocramius/performance/collection-contains

Minor performance optimization for lookups of `ArrayCollection#contains()`
  • Loading branch information...
commit bc6bc47132613b28a58b7293dfd7872d9e3bcff3 2 parents c07ce5f + a152e34
@guilhermeblanco guilhermeblanco authored
Showing with 1 addition and 7 deletions.
  1. +1 −7 lib/Doctrine/Common/Collections/ArrayCollection.php
View
8 lib/Doctrine/Common/Collections/ArrayCollection.php
@@ -229,13 +229,7 @@ public function containsKey($key)
*/
public function contains($element)
{
- foreach ($this->_elements as $collectionElement) {
- if ($element === $collectionElement) {
- return true;
- }
- }
-
- return false;
+ return in_array($element, $this->_elements, true);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.