From: Kir Kolyshkin Date: Fri, 30 Aug 2024 07:23:50 +0000 (-0700) Subject: internal/testenv: use sync.OnceValues for hasSymlink X-Git-Tag: go1.24rc1~1052 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=995c816a7a9190db1ac0870cf2c424385b03ac4b;p=gostls13.git internal/testenv: use sync.OnceValues for hasSymlink On some platforms (android, wasip1) this function is called many times which probably results in some slowdown, especially for wasip1. Wrap it into sync.OnceValues. Change-Id: Id290ffd8d1e7ad806302f457e8fff2e3123b49a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/609418 LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- diff --git a/src/internal/testenv/testenv_notwin.go b/src/internal/testenv/testenv_notwin.go index 30e159a6ec..9dddea94d0 100644 --- a/src/internal/testenv/testenv_notwin.go +++ b/src/internal/testenv/testenv_notwin.go @@ -11,9 +11,10 @@ import ( "os" "path/filepath" "runtime" + "sync" ) -func hasSymlink() (ok bool, reason string) { +var hasSymlink = sync.OnceValues(func() (ok bool, reason string) { switch runtime.GOOS { case "plan9": return false, "" @@ -43,4 +44,4 @@ func hasSymlink() (ok bool, reason string) { } return true, "" -} +})