-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use sync.OnceFunc instead of sync.Once
sync.OnceFunc was added in Go 1.21 and simplifies the code slightly. Worth noting that, compared to Once, OnceFunc does a bit more work as it replays any panic that happens on the first call: goos: linux goarch: amd64 pkg: github.com/go-json-experiment/json cpu: AMD Ryzen 7 PRO 5850U with Radeon Graphics │ old │ new │ │ sec/op │ sec/op vs base │ Testdata/CanadaGeometry/Marshal/Concrete-8 1.311m ± 0% 1.339m ± 0% +2.17% (p=0.002 n=6) Testdata/CanadaGeometry/Marshal/Interface-8 1.347m ± 1% 1.434m ± 0% +6.46% (p=0.002 n=6) Testdata/CanadaGeometry/Unmarshal/Concrete-8 1.832m ± 0% 1.867m ± 0% +1.92% (p=0.002 n=6) Testdata/CanadaGeometry/Unmarshal/Interface-8 2.962m ± 0% 2.827m ± 1% -4.54% (p=0.002 n=6) geomean 1.759m 1.785m +1.43%
- Loading branch information
Showing
1 changed file
with
23 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters