Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of if key exists in the array #235

Merged
merged 1 commit into from Dec 18, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Collections/ArrayCollection.php
Expand Up @@ -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]);

Expand Down Expand Up @@ -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);
}

/**
Expand Down