[php-src] PR #12712: Use binary search for cp932ext*_ucs_table lookups
| From: | nielsdos | Date: | Fri, 17 Nov 2023 21:12:37 +0000 |
| Subject: | [php-src] PR #12712: Use binary search for cp932ext*_ucs_table lookups | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-24233@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12712
Author: nielsdos
A large amount of time is spent doing a linear search through these tables in the CP932 encoding.
Instead of that, we can add sorted versions of these tables that also store the index of the
non-sorted version and perform a binary search on those sorted versions.
This reduces the time spent from 1.54s to 0.91s for the reference benchmark [1].
[1] https://github.com/php/php-src/issues/12684#issuecomment-1813799924
Sorted table generation code: https://gist.github.com/nielsdos/ca1ff1d37a3ed9bc1d7b37c14b24c3e9
(The table has the data for
cp932ext1_ucs_table already filled in, replace it with
cp932ext3_ucs_table to generate the other table)