From 0f64d7f9cc295a4468db91254dc196fa6c3d7aff Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 7 Apr 2020 22:22:36 -0700 Subject: [PATCH] wgengine: remove a tiny allocation Drop in the bucket compared to the larger issues, but noticed it when looking at pprof. --- wgengine/userspace.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wgengine/userspace.go b/wgengine/userspace.go index 30272903e..ee3593dcd 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -481,11 +481,9 @@ func (e *userspaceEngine) getStatus() (*Status, error) { var hst1, hst2, n int64 var err error for _, line := range lines { - kv := strings.SplitN(line, "=", 2) - var k, v string - k = kv[0] - if len(kv) > 1 { - v = kv[1] + k, v := line, "" + if i := strings.IndexByte(line, '='); i != -1 { + k, v = line[:i], line[i+1:] } switch k { case "public_key":