[ticket/9669] Add isNormalized checks for performance

Since isNormalized is less expensive than normalize[1] and normalization
will be applied repeatedly in most cases[2], it's more efficient to
check for isNormalized.

[1] http://area51.phpbb.com/phpBB/viewtopic.php?f=81&t=32718&p=208005#p208005
[2] phpBB 3.0 has a call to utf8_normalize_nfc wrapped around any
multibyte request_var call.

PHPBB3-9669
This commit is contained in:
Igor Wiedler 2010-04-26 20:46:09 +02:00
parent e8cc26e79c
commit 66c116f7de

View file

@ -1778,9 +1778,13 @@ else
if (!is_array($strings))
{
$strings = Normalizer::normalize($strings);
if (Normalizer::isNormalized($strings))
{
return $strings;
}
if (is_array($strings))
return Normalizer::normalize($strings);
}
else
{
foreach ($strings as $key => $string)
{
@ -1788,11 +1792,19 @@ else
{
foreach ($string as $_key => $_string)
{
if (Normalizer::isNormalized($strings[$key][$_key]))
{
continue;
}
$strings[$key][$_key] = Normalizer::normalize($strings[$key][$_key]);
}
}
else
{
if (Normalizer::isNormalized($strings[$key]))
{
continue;
}
$strings[$key] = Normalizer::normalize($strings[$key]);
}
}