decred / dcrd

Decred daemon in Go (golang).
https://decred.org
ISC License
733 stars 289 forks source link

mixing: Reduce a couple of allocation cases. #3298

Closed davecgh closed 3 months ago

davecgh commented 4 months ago

The Hash method on wire messages unfortunately involves allocations, so it's generally best to keep the result as a local and use that local through to avoid more allocs.

Also, since fmt.Errorf involves interfaces, taking the address of the local session id forces it to the heap. It's faster to copy it into the interface instead and avoid the GC hit.