[DependencyInjection] made a small performance enhancement. No need to lowercase three times the same.
`strtolower` was called three times at most on the same value, and one at least. To avoid this, let's compute it first. Additionally, $value cast in last return clause was useless as it has been done previously, and nothing changed $value's value. Signed-off-by: Romain Dorgueil <romain.dorgueil@symfony-project.com>
This commit is contained in:
parent
8948ae1f6e
commit
3671f4a08a
@ -65,23 +65,24 @@ class SimpleXMLElement extends \SimpleXMLElement
|
||||
static public function phpize($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
$lowercaseValue = strtolower($value);
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case 'null' == strtolower($value):
|
||||
case 'null' === $lowercaseValue:
|
||||
return null;
|
||||
case ctype_digit($value):
|
||||
return '0' == $value[0] ? octdec($value) : intval($value);
|
||||
case 'true' === strtolower($value):
|
||||
case 'true' === $lowercaseValue:
|
||||
return true;
|
||||
case 'false' === strtolower($value):
|
||||
case 'false' === $lowercaseValue:
|
||||
return false;
|
||||
case is_numeric($value):
|
||||
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
|
||||
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $value):
|
||||
return floatval(str_replace(',', '', $value));
|
||||
default:
|
||||
return (string) $value;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user