stream-vbyte-go
stream-vbyte-go copied to clipboard
slice based look up
Map lookup in the decode path is having performance implications and a fix by replacing the map look up with a slice look up improves the performance like below.
For 10K numbers
BenchmarkTestSvbDecode-8 10000 112119 ns/op 0 B/op 0 allocs/op
With slice look up,
var lookup = [][4]uint8{
0x00: [4]uint8{1, 1, 1, 1},
0x01: [4]uint8{1, 1, 1, 2},
BenchmarkTestSvbDecode-8 30000 46381 ns/op 0 B/op 0 allocs/op