From 3671f4a08a35a797b12251f8b89fe4b009e6e0a4 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Thu, 25 Feb 2010 15:19:44 +0100 Subject: [PATCH] [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 --- .../Components/DependencyInjection/SimpleXMLElement.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php b/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php index 3c1cf337e0..41700111e4 100644 --- a/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php +++ b/src/Symfony/Components/DependencyInjection/SimpleXMLElement.php @@ -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; } } }