[Question] append vs. bytes.Buffer-like "manual cap/len check and copy"
I noticed your ByteBuffer grows via append, whereas we know the bytes.Buffer grows by hand-coded comparison of cap/len and enlarging/copying when needed.
For this very small specific sub-aspect of your overall buffer-pool project, did you bench both approaches? Did you:
- verify
appendto be visibly, noticably, consistently "faster"/more-performant (perhaps because it compiles to better asm..) than a hand-rolled grow logic? - or did you just go for
appendfor the simplicity? :smirk:
I'm curious in this mainly because I too keep around a lean tiny private alternative to bytes.Buffer (without your pooling aspects — not needed so far) and I was wondering if append might not be "intrinsically preferable", after all this growth logic is exactly its purpose. :grin: but then it makes me wonder why bytes.Buffer went for hand-rolled growth and avoiding append.
Since you have seen more heavy loads in your real-world projects so far than I did in my still-toy-stage usage so far, I figured you're the guy whose opinion to ask! =)