Verify whether value is already normalized
Apparently `normalizer_normalize` is not verifying itself whether the string needs to be converted or not. Or does it at least not very performantly. This simple change leads to a 4% performance gain on the processing of normalizeUnicode. Since this method is called quite often (i.e. for every file path) this has actually a measurable impact. For examples searches are now 200ms faster on my machine. Still not perfect but way to go. Part of https://github.com/owncloud/core/issues/13221
This commit is contained in:
parent
ae3483299c
commit
e80ece9a2b
|
@ -1274,16 +1274,19 @@ class OC_Util {
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public static function normalizeUnicode($value) {
|
public static function normalizeUnicode($value) {
|
||||||
$normalizedValue = normalizer_normalize($value);
|
if(Normalizer::isNormalized($value)) {
|
||||||
if ($normalizedValue === null || $normalizedValue === false) {
|
return $value;
|
||||||
\OC_Log::write('core', 'normalizing failed for "' . $value . '"', \OC_Log::WARN);
|
|
||||||
} else {
|
|
||||||
$value = $normalizedValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$normalizedValue = Normalizer::normalize($value);
|
||||||
|
if ($normalizedValue === null || $normalizedValue === false) {
|
||||||
|
\OC::$server->getLogger()->warning('normalizing failed for "' . $value . '"', ['app' => 'core']);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $normalizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param boolean|string $file
|
* @param boolean|string $file
|
||||||
* @return string
|
* @return string
|
||||||
|
|
Loading…
Reference in New Issue