From 0f86a33b610c8fd97c468ba11ecca131476ff395 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 18 Aug 2012 17:12:41 +0200 Subject: [PATCH] micro-optim: replace for with foreach --- src/Symfony/Component/Form/Util/FormUtil.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Form/Util/FormUtil.php b/src/Symfony/Component/Form/Util/FormUtil.php index b4048f76a6..5e8d461698 100644 --- a/src/Symfony/Component/Form/Util/FormUtil.php +++ b/src/Symfony/Component/Form/Util/FormUtil.php @@ -113,13 +113,13 @@ abstract class FormUtil $lowerPluralRev = strtolower($pluralRev); $pluralLength = strlen($lowerPluralRev); - // The outer loop $i iterates over the entries of the plural table + // The outer loop iterates over the entries of the plural table // The inner loop $j iterates over the characters of the plural suffix // in the plural table to compare them with the characters of the actual // given plural suffix - for ($i = 0, $numPlurals = count(self::$pluralMap); $i < $numPlurals; ++$i) { - $suffix = self::$pluralMap[$i][0]; - $suffixLength = self::$pluralMap[$i][1]; + foreach (self::$pluralMap as $map) { + $suffix = $map[0]; + $suffixLength = $map[1]; $j = 0; // Compare characters in the plural table and of the suffix of the @@ -135,19 +135,19 @@ abstract class FormUtil if ($j < $pluralLength) { $nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]); - if (!self::$pluralMap[$i][2] && $nextIsVocal) { + if (!$map[2] && $nextIsVocal) { // suffix may not succeed a vocal but next char is one break; } - if (!self::$pluralMap[$i][3] && !$nextIsVocal) { + if (!$map[3] && !$nextIsVocal) { // suffix may not succeed a consonant but next char is one break; } } $newBase = substr($plural, 0, $pluralLength - $suffixLength); - $newSuffix = self::$pluralMap[$i][4]; + $newSuffix = $map[4]; // Check whether the first character in the plural suffix // is uppercased. If yes, uppercase the first character in