|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-01-15 14:18 UTC] legale dot legale at gmail dot com
-Status: Open
+Status: Closed
[2019-01-15 14:18 UTC] legale dot legale at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 11:00:01 2025 UTC |
Description: ------------ There is a problem with mbfl library functions. UTF-16, UTF-16BE, UTF-16LE encodings are parsed by the slow path (variable width multibyte encodings). Test script: --------------- <?php function bmark() { $args = func_get_args(); $len = count($args); if ($len < 3) { trigger_error("At least 3 args expected. Only $len given.", 256); return false; } $cnt = array_shift($args); $fun = array_shift($args); $start = microtime(true); $i = 0; while ($i < $cnt) { $i++; $res = call_user_func_array($fun, $args); } $end = microtime(true) - $start; return $end; } $i = 1000; $str32 = mb_convert_encoding(str_repeat("строка", $i), "UTF-32", "UTF-8"); $str16 = mb_convert_encoding(str_repeat("строка", $i), "UTF-16", "UTF-8"); echo "str16: " . bmark($i, "mb_substr", $str16, 0, null, "UTF-16") . PHP_EOL; echo "str32: " . bmark($i, "mb_substr", $str32, 0, null, "UTF-32") . PHP_EOL; ?> Expected result: ---------------- UTF-16 and UTF-32 parsing speed should be mostly the same. Actual result: -------------- str16: 0.13957190513611 str32: 0.026632070541382