diff options
Diffstat (limited to 'Core/Util')
-rw-r--r-- | Core/Util/StringUtils.php | 9 |
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'); } |