Skip to content

Commit 39dc0cb

Browse files
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 see a significanly higher speedup Also expand on test coverage
1 parent bba4a58 commit 39dc0cb

File tree

1 file changed

+317
-95
lines changed

1 file changed

+317
-95
lines changed

0 commit comments

Comments
 (0)