Permalink
Browse files

Micro-optimization

  • Loading branch information...
1 parent 7b430b1 commit 30494b8a8ffde6c26397a0b252dc96cd3e42f2c7 @dlsniper dlsniper committed with fabpot Jan 13, 2013
Showing with 12 additions and 6 deletions.
  1. +4 −2 Dumper/PhpDumper.php
  2. +4 −2 Tests/Fixtures/php/services10.php
  3. +4 −2 Tests/Fixtures/php/services9_compiled.php
View
6 Dumper/PhpDumper.php
@@ -746,7 +746,7 @@ public function getParameter(\$name)
{
\$name = strtolower(\$name);
- if (!array_key_exists(\$name, \$this->parameters)) {
+ if (!(isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name));
}
@@ -758,7 +758,9 @@ public function getParameter(\$name)
*/
public function hasParameter(\$name)
{
- return array_key_exists(strtolower(\$name), \$this->parameters);
+ \$name = strtolower(\$name);
+
+ return isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters);
}
/**
View
6 Tests/Fixtures/php/services10.php
@@ -55,7 +55,7 @@ public function getParameter($name)
{
$name = strtolower($name);
- if (!array_key_exists($name, $this->parameters)) {
+ if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
@@ -67,7 +67,9 @@ public function getParameter($name)
*/
public function hasParameter($name)
{
- return array_key_exists(strtolower($name), $this->parameters);
+ $name = strtolower($name);
+
+ return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters);
}
/**
View
6 Tests/Fixtures/php/services9_compiled.php
@@ -191,7 +191,7 @@ public function getParameter($name)
{
$name = strtolower($name);
- if (!array_key_exists($name, $this->parameters)) {
+ if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
@@ -203,7 +203,9 @@ public function getParameter($name)
*/
public function hasParameter($name)
{
- return array_key_exists(strtolower($name), $this->parameters);
+ $name = strtolower($name);
+
+ return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters);
}
/**

0 comments on commit 30494b8

Please sign in to comment.