[php-src] PR #25707: Fix iconv_strlen() being hundreds of times too slow on glibc

From: Date: Tue, 24 Nov 2026 13:17:51 +0000
Subject: [php-src] PR #25707: Fix iconv_strlen() being hundreds of times too slow on glibc
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-40959@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25707 Author: lacatoire iconv_strlen() converted the string to UCS-4 through an 8-byte buffer, so iconv() was called once per two characters, and each of those calls is slow on glibc. iconv_substr() always calls it first, and iconv_strpos() does with a negative offset, so they paid that cost too. Use a 4 KiB buffer. ### To reproduce ```php <?php $s = str_repeat("é", 1000000); $t = microtime(true); iconv_strlen($s, "UTF-8"); printf("%.2fs\n", microtime(true) - $t); ``` PHP 8.4.28-dev, glibc 2.36 Before: 10.47s After: 0.03s

« previous php.git-pulls (#40959) next »