Skip to content

Commit da48ade

Browse files
committed
Optimize Reader.takeLeb128
Rewrite `Reader.takeLeb128` to not use `takeMultipleOf7Leb128` and instead: * Use byte aligned integers * 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 12x(!) performance improvement. Outside of that: For u8, u16 and u64 performance increases ~1.5x to ~6x 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/7ed5fe
1 parent 64e22b7 commit da48ade

File tree

1 file changed

+338
-100
lines changed

1 file changed

+338
-100
lines changed

0 commit comments

Comments
 (0)