The type I am writing can be easily encoded as a sequence of ints. When I wrote MarshalBinary for my type, I decided to GobEncode this sequence of ints to a byte buffer and return the bytes. I learned that GobEncoding an empty slice of int takes 18 bytes. So even for small instances of my type, I am paying for 18 extra bytes of overhead to encode. I chose Gob because it uses variable length encoding for ints, so smaller ints require fewer bytes to encode.
Since I know that I will always be encoding and decoding an []int, is there a better way to implement MarshalBinary without reimplementing the variable length encoding of ints from scratch? Thank you in advance. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/983c6c04-2473-42f1-be29-371e85d66480n%40googlegroups.com.