summaryrefslogtreecommitdiffstats
path: root/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Core')
-rw-r--r--Core/Util/StringUtils.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/Core/Util/StringUtils.php b/Core/Util/StringUtils.php
index 62dccd8..861e94c 100644
--- a/Core/Util/StringUtils.php
+++ b/Core/Util/StringUtils.php
@@ -72,7 +72,14 @@ class StringUtils
*/
public static function safeStrlen($string)
{
- if (function_exists('mb_strlen')) {
+ // Premature optimization
+ // Since this cannot be changed at runtime, we can cache it
+ static $func_exists = null;
+ if ($func_exists === null) {
+ $func_exists = function_exists('mb_strlen');
+ }
+
+ if ($func_exists) {
return mb_strlen($string, '8bit');
}