Permalink
Browse files

Optimized getParameter.

  • Loading branch information...
1 parent 1635e0a commit 79ff1f10d2d6553d0a73203c8267e1acd9e8d98c @guilhermeblanco guilhermeblanco committed May 28, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/Doctrine/ORM/AbstractQuery.php
@@ -166,14 +166,15 @@ public function getParameters()
*/
public function getParameter($key)
{
- foreach ($this->parameters->getIterator() as $parameter) {
- // Must not be identical because of string to integer conversion
- if ($parameter->getName() == $key) {
- return $parameter;
+ $filteredParameters = $this->parameters->filter(
+ function ($parameter) use ($key)
+ {
+ // Must not be identical because of string to integer conversion
+ return ($key == $parameter->getName());
}
- }
+ );
- return null;
+ return count($filteredParameters) ? $filteredParameters->first() : null;
}
/**

0 comments on commit 79ff1f1

Please sign in to comment.