mirror of
https://github.com/php/php-src.git
synced 2026-04-24 16:38:25 +02:00
7658220599
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. [1] https://github.com/php/php-src/issues/12684#issuecomment-1813799924