valyala / bytebufferpool

Anti-memory-waste byte buffer pool
MIT License
1.19k stars 132 forks source link

Rename ByteBuffer.B to ByteBuffer.buf #11

Closed n10v closed 8 years ago

n10v commented 8 years ago

I think, it's better to use private underlying bytes slice

n10v commented 8 years ago

So, what do you think of it?

wI2L commented 8 years ago

@bogem How would we use the AppendX functions of strconv package with a private underlying byte slice ?

n10v commented 8 years ago

@wI2L By creating a new method:

func (b *ByteBuffer) AppendX(v X) {
    b.buf = strconv.AppendX(b.buf, v)
}
valyala commented 8 years ago

I think, it's better to use private underlying bytes slice

Probably yes, but it is too late to change public API, since it may break existing code. I'd recommend forking the package and integrate these changes there.

wI2L commented 8 years ago

@bogem In my use case, having a public underlying byte slice allow me to pass it to a chain of function in an append-like serialization process, which is effectively very convenient. The serialization functions takes a []byte as argument and return it, so I can either use this package if I want something optimized, or simply pass a new byte slice from scratch.

Others methods of the buffer (Write, WriteByte..) are only a convenience, so as your AppendX proposal would be.

Like @valyala said, its too late to change it, but honestly I can't see how "it's better" to have a private underlying byte.