[php-src] PR #12707: Improve performance of mbfl_name2encoding() by using perfect hashing

From: Date: Fri, 17 Nov 2023 16:58:25 +0000
Subject: [php-src] PR #12707: Improve performance of mbfl_name2encoding() by using perfect hashing
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-24225@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/12707 Author: nielsdos mbfl_name2encoding() uses a linear loop through the encodings, comparing the name one by one, which is very slow. For the benchmark [1] just looking up the name takes about 50% of run-time. By using perfect hashing instead, we no longer have to loop over the list, and the number of string comparisons is reduced to just a single one. The perfect hashing table is generated using GNU gperf and amended manually to fit in with mbstring and manually changed to reduce the cache size. Previously the linked benchmark took 2.39s on my system, now it takes 1.50s. This is a nice improvement that can be felt when processing large amounts of data. [1] https://github.com/php/php-src/issues/12684#issuecomment-1813799924

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