miekg/dns — pull request #73 by majek (2014-01-10 14:14:09+00:00)
Title: Introduce msg.PackWithBuffer() - it's like msg.Pack() but can reuse a byte buffer

Introduce msg.PackWithBuffer() - it's like msg.Pack() but can reuse a byte buffer

msg.Pack() always allocates a byte slice. This is good for simplicity,
but in a serious application it's preferable to reuse byte slices to
reduce the GC overhead. This patch introduces a new public method:
PackWithBuffer(). It's exaclty like Pack() but is able to reuse a
given byte slice. It will still allocate a new slice if the given one
is too small.