mirror of
https://github.com/netsampler/goflow2.git
synced 2024-05-06 15:54:52 +00:00
Instead of allocating small slices, we rely on the fact that most call sites are providing a `bytes.Buffer` and use the `Next()` method. For sFlow decoding, in my case, we get a 33% speedup. A `bytes.Reader` would even be more efficient, but unfortunately, they don't have a `Next()` method. While Go should be smart enough to make the allocation of `bs` on the stack, it does not, even when `io.ReadFull()` is inlines. ``` decoders/utils/utils.go:23:13: make([]byte, n) escapes to heap ```