Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #235 from basico/master

Improve performance of if key exists in the array
  • Loading branch information...
commit a890fe1b689ed65c52bf4a7e64333a27b3c400d6 2 parents d514e39 + d2ee571
@guilhermeblanco guilhermeblanco authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Doctrine/Common/Collections/ArrayCollection.php
View
4 lib/Doctrine/Common/Collections/ArrayCollection.php
@@ -120,7 +120,7 @@ public function current()
*/
public function remove($key)
{
- if (array_key_exists($key, $this->_elements)) {
+ if (isset($this->_elements[$key]) || array_key_exists($key, $this->_elements)) {
$removed = $this->_elements[$key];
unset($this->_elements[$key]);
@@ -214,7 +214,7 @@ public function offsetUnset($offset)
*/
public function containsKey($key)
{
- return array_key_exists($key, $this->_elements);
+ return isset($this->_elements[$key]) || array_key_exists($key, $this->_elements);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.