[php-src] Issue #12684: PHP8.1 Slow processing speed of string operations

From: Date: Thu, 16 Nov 2023 02:48:02 +0000
Subject: [php-src] Issue #12684: PHP8.1 Slow processing speed of string operations
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245811@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12684 Author: toshimitsu-sato ### Description Does not occur in PHP8.0 The following code is slow when updated to PHP8.1 The functions used are below * strlen * mb_convert_encoding * str_replace The following code: 3500 data are set in $data In PHP8.0 it takes 2 seconds to complete. It takes 3 minutes with PHP8.1 ```php <?php foreach ($data as $record) { $csvData = array(); foreach (array_values((array)$record) as $item) { if (strlen($item) !== strlen(mb_convert_encoding(mb_convert_encoding($item, 'SJIS-win', 'UTF-8'), 'UTF-8', 'SJIS-win'))) { $notExistsUnicodeValues[] = $item; } else { $csvData[] = str_replace(array("\r\n", "\r", "\n"), "\n", $item); } } } ``` ### PHP Version PHP 8.1.0 ### Operating System Ubuntu 20.04

« previous php.bugs (#245811) next »