wgengine/magicsock: remove final alloc from ReceiveFrom

And now that we don't have to play escape analysis and inlining games,
simplify the code.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2022-03-15 15:33:06 -07:00
committed by Josh Bleecher Snyder
parent 463728a885
commit 1b57b0380d
3 changed files with 25 additions and 23 deletions

View File

@@ -1345,14 +1345,18 @@ func TestReceiveFromAllocs(t *testing.T) {
}
// Go 1.16 and before: allow 3 allocs.
// Go 1.17: allow 2 allocs.
// Go Tailscale fork, Go 1.18+: allow 1 alloc.
// Go 1.17, Tailscale fork: allow 1 alloc.
// Go 1.18+: allow 0 allocs.
// Go 2.0: allow -1 allocs (projected).
major, ts := goMajorVersion(runtime.Version())
maxAllocs := 3
switch {
case major == 17:
case major == 17 && !ts:
maxAllocs = 2
case major >= 18, ts:
case major == 17 && ts:
maxAllocs = 1
case major >= 18:
maxAllocs = 0
}
t.Logf("allowing %d allocs for Go version %q", maxAllocs, runtime.Version())
roundTrip := setUpReceiveFrom(t)