Commit 7bc65bc
perf(iconv): EUC-JP encode direct table — 2.39x, now beats glibc 2.1x
encode_eucjp was the one DBCS encoder still doing a per-char binary_search
over EUC_JP_ENC (13,169 entries, ~14 cache-missing probes); every other DBCS
encoder was converted to a direct table in 6750bb6 but EUC-JP has 3-byte
(0x8F-plane) packed forms that the generic encode_dbcs2 doesn't handle, so it
was missed. Replace with a lazy OnceLock direct cp->packed table ([u32;0x10000],
packed+1 so 0=unrepresentable); every EUC-JP-encodable cp is BMP (max key
0xFFE5) so the table is exhaustive and byte-identical to the binary search.
UTF-8->EUC-JP encode: 11.413 -> 4.770 ns/B = 2.39x self-speedup;
vs glibc 1.26x SLOWER -> 0.47x (2.1x FASTER than glibc, glibc 10.07 ns/B).
Isomorphism: iconv_differential_fuzz (4 tests, 0 divergences vs host glibc;
iconv_cjk_differential_fuzz_vs_glibc exercises UTF-8<->EUC-JP byte-for-byte +
errno + inbytesleft over 6000 CJK-biased inputs).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 6750bb6 commit 7bc65bc
1 file changed
Lines changed: 40 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8433 | 8433 | | |
8434 | 8434 | | |
8435 | 8435 | | |
8436 | | - | |
8437 | | - | |
8438 | | - | |
8439 | | - | |
8440 | | - | |
8441 | | - | |
8442 | | - | |
8443 | | - | |
8444 | | - | |
8445 | | - | |
8446 | | - | |
8447 | | - | |
8448 | | - | |
8449 | | - | |
8450 | | - | |
8451 | | - | |
8452 | | - | |
8453 | | - | |
8454 | | - | |
8455 | | - | |
8456 | | - | |
8457 | | - | |
8458 | | - | |
8459 | | - | |
8460 | | - | |
| 8436 | + | |
| 8437 | + | |
| 8438 | + | |
| 8439 | + | |
| 8440 | + | |
| 8441 | + | |
| 8442 | + | |
| 8443 | + | |
| 8444 | + | |
| 8445 | + | |
| 8446 | + | |
| 8447 | + | |
8461 | 8448 | | |
8462 | 8449 | | |
8463 | | - | |
| 8450 | + | |
| 8451 | + | |
| 8452 | + | |
| 8453 | + | |
| 8454 | + | |
| 8455 | + | |
| 8456 | + | |
| 8457 | + | |
| 8458 | + | |
| 8459 | + | |
| 8460 | + | |
| 8461 | + | |
| 8462 | + | |
| 8463 | + | |
| 8464 | + | |
| 8465 | + | |
| 8466 | + | |
| 8467 | + | |
| 8468 | + | |
| 8469 | + | |
| 8470 | + | |
| 8471 | + | |
| 8472 | + | |
| 8473 | + | |
| 8474 | + | |
| 8475 | + | |
| 8476 | + | |
| 8477 | + | |
8464 | 8478 | | |
8465 | 8479 | | |
8466 | 8480 | | |
| |||
0 commit comments