diff options
author | Scott Arciszewski <scott@arciszewski.me> | 2015-03-23 11:26:23 -0400 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2015-03-25 10:28:01 +0100 |
commit | 36bb08f5baa5b7d684413b2c6ca8daa0b77066d6 (patch) | |
tree | 10a693814182031139f08e31f60fddbeaefdb6dc /Core/Util | |
parent | 5baa64270854c29298ddca9a8952361fbcfce889 (diff) | |
download | symfony-security-36bb08f5baa5b7d684413b2c6ca8daa0b77066d6.zip symfony-security-36bb08f5baa5b7d684413b2c6ca8daa0b77066d6.tar.gz symfony-security-36bb08f5baa5b7d684413b2c6ca8daa0b77066d6.tar.bz2 |
Update StringUtils.php
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'); } |