summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-01-09 23:34:26 +0100
committerLukas Reschke <lukas@owncloud.com>2015-01-10 12:12:40 +0100
commite80ece9a2b39d18eea356196a08211c6b36a4048 (patch)
tree5cd8837d5bae6b1caca4fffd1ea1ed7bcfe81b3e /lib
parentae3483299cc8bfc226d8fe2a2501fd32c745c745 (diff)
downloadnextcloud-server-e80ece9a2b39d18eea356196a08211c6b36a4048.tar.gz
nextcloud-server-e80ece9a2b39d18eea356196a08211c6b36a4048.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/private/util.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/private/util.php b/lib/private/util.php
index 3178639b02e..ec3640503e4 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -1274,14 +1274,17 @@ class OC_Util {
* @return bool|string
*/
public static function normalizeUnicode($value) {
- $normalizedValue = normalizer_normalize($value);
+ if(Normalizer::isNormalized($value)) {
+ return $value;
+ }
+
+ $normalizedValue = Normalizer::normalize($value);
if ($normalizedValue === null || $normalizedValue === false) {
- \OC_Log::write('core', 'normalizing failed for "' . $value . '"', \OC_Log::WARN);
- } else {
- $value = $normalizedValue;
+ \OC::$server->getLogger()->warning('normalizing failed for "' . $value . '"', ['app' => 'core']);
+ return $value;
}
- return $value;
+ return $normalizedValue;
}
/**