]> Cypherpunks repositories - gostls13.git/commit
net/netip: reduce allocations in MarshalBinary
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 3 Nov 2021 14:16:01 +0000 (15:16 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 5 Nov 2021 22:28:56 +0000 (22:28 +0000)
commit87a3fc518a462a6bef4c395ec5af26f2cdc41207
tree3f1a988d7a78937f402fa5d28d629da9edc3bc25
parentfeb024f4153395e5bbb2a51bb3d1ddc4f5b0d2dc
net/netip: reduce allocations in MarshalBinary

Addr's MarshalBinary required two allocations in the case of a zone
existing, and AddrPort and Prefix both required three. This refactors
things slightly so that each marshal function only needs a single
allocation.

Change-Id: I9bde9969fedc1cad64bebb607188c4287f6a0d01
Reviewed-on: https://go-review.googlesource.com/c/go/+/361054
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/netip/netip.go