Skip to content

Commit

Permalink
Replace dead overflow checks with assertions and avoid indirect call …
Browse files Browse the repository at this point in the history
…overhead

We allocate twice the input length, and every input character results in
either 1 or 2 output bytes, so we cannot overflow.

By using an enum, and a switch table (which will be efficiently compiled
into a jump table), we can avoid the pessimistic code generation of the
indirect calls.

With this I get the following runtime for the test script in GH-13466 on
my i7-4790, which is around 1.25x faster.
  Time (mean ± σ):     250.9 ms ±   1.6 ms    [User: 248.4 ms, System: 2.0 ms]
  Range (min … max):   248.9 ms … 254.4 ms    11 runs
  • Loading branch information
nielsdos committed Mar 7, 2024
1 parent 3798966 commit 1571eed
Show file tree
Hide file tree
Showing 2 changed files with 352 additions and 302 deletions.
Loading

0 comments on commit 1571eed

Please sign in to comment.