micro-optim: replace for with foreach
This commit is contained in:
parent
4efb9fec50
commit
0f86a33b61
@ -113,13 +113,13 @@ abstract class FormUtil
|
|||||||
$lowerPluralRev = strtolower($pluralRev);
|
$lowerPluralRev = strtolower($pluralRev);
|
||||||
$pluralLength = strlen($lowerPluralRev);
|
$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
|
// 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
|
// in the plural table to compare them with the characters of the actual
|
||||||
// given plural suffix
|
// given plural suffix
|
||||||
for ($i = 0, $numPlurals = count(self::$pluralMap); $i < $numPlurals; ++$i) {
|
foreach (self::$pluralMap as $map) {
|
||||||
$suffix = self::$pluralMap[$i][0];
|
$suffix = $map[0];
|
||||||
$suffixLength = self::$pluralMap[$i][1];
|
$suffixLength = $map[1];
|
||||||
$j = 0;
|
$j = 0;
|
||||||
|
|
||||||
// Compare characters in the plural table and of the suffix of the
|
// Compare characters in the plural table and of the suffix of the
|
||||||
@ -135,19 +135,19 @@ abstract class FormUtil
|
|||||||
if ($j < $pluralLength) {
|
if ($j < $pluralLength) {
|
||||||
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
|
$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
|
// suffix may not succeed a vocal but next char is one
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::$pluralMap[$i][3] && !$nextIsVocal) {
|
if (!$map[3] && !$nextIsVocal) {
|
||||||
// suffix may not succeed a consonant but next char is one
|
// suffix may not succeed a consonant but next char is one
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
|
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
|
||||||
$newSuffix = self::$pluralMap[$i][4];
|
$newSuffix = $map[4];
|
||||||
|
|
||||||
// Check whether the first character in the plural suffix
|
// Check whether the first character in the plural suffix
|
||||||
// is uppercased. If yes, uppercase the first character in
|
// is uppercased. If yes, uppercase the first character in
|
||||||
|
Reference in New Issue
Block a user