Commit 21ff57a
committed
Optimize Reader.takeLeb128
Rewrite `Reader.takeLeb128` to not use `takeMultipleOf7Leb128` and
instead:
* Use byte aligned integers
* Turn the decoding into a finite state machine
* Turn the main reading loop into an inlined loop of static length
* Special case small integers (<= 7 bits)
Across larger integers (> 7 bits) this roughly doubles performance in a
[micro-benchmark](https://zigbin.io/b8b396), however with some notable
exceptions:
* `i50` sees barely any speedup and `u50` even sees a minor slowdown. I
have genuinely no clue what could be causing this, it's the exception
to the rule.
* 8, 16 and 32 bit integers see a significantly higher speedup
Also expand on test coverage1 parent 1309994 commit 21ff57a
1 file changed
+317
-95
lines changed
0 commit comments