Apply sync.Pool to cache packet conn buf object instead of creating one each time.
Why is this useful?
This is an optimisation that alleviates the GC pressure by reducing allocation of packet conn buf object.
Other details:
There is no need to reset packet conn buf object before putting it back to sync.Pool. This is because we want to reserve the size of buf and the number of bytes will be specified each time.
The input parameters of internal goroutine function are unnecessary as those variables are safe and accessible to the namespace shared with the internal goroutine function.
What are the changes?
Why is this useful?
Other details: