Commit 309fd8d
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)
Notably signed and unsigned 32 bit integers have 5x to 10x(!)
performance improvement.
Outside of that:
For u8, u16 and u64 performance increases ~1.5x to 5x
For i8, i16 and i64 performance increases ~1.5x to 3.5x
For integers with bit multiples of 7 performance is roughly equal within the
margin or error.
Also expand on test coverage
Microbenchmark: https://zigbin.io/7ed5fe1 parent 7cb51ad commit 309fd8d
1 file changed
+336
-100
lines changed
0 commit comments