summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-11-06 15:21:44 +0000
committertb <>2023-11-06 15:21:44 +0000
commit87d360b18096203504ff4777c6c377a03809d910 (patch)
tree2725899380fcff86d14b7c9a0115a86afdf1c84b /src
parent6bd8fde74febe6a7c04fc39b3a2b86a6291a0ee6 (diff)
downloadopenbsd-87d360b18096203504ff4777c6c377a03809d910.tar.gz
openbsd-87d360b18096203504ff4777c6c377a03809d910.tar.bz2
openbsd-87d360b18096203504ff4777c6c377a03809d910.zip
Pull everything except the actual run call out of the closure
The determination of the test group type and the JSON unmarshalling can be done before the closure without performance impact. This is more readable and eliminates the need of a temporary variable again. Suggested by jsing
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index feeb6c897f..39f1456b67 100644
--- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go
+++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
@@ -1,4 +1,4 @@
1/* $OpenBSD: wycheproof.go,v 1.150 2023/11/06 15:17:02 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.151 2023/11/06 15:21:44 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org>
@@ -2830,17 +2830,15 @@ func runTestVectors(path string, variant testVariant) bool {
2830 2830
2831 success := true 2831 success := true
2832 for _, tg := range wtv.TestGroups { 2832 for _, tg := range wtv.TestGroups {
2833 testGroupJSON := tg 2833 wtg := testGroupFromAlgorithm(wtv.Algorithm, variant)
2834 if wtg == nil {
2835 log.Printf("INFO: Unknown test vector algorithm %q", wtv.Algorithm)
2836 return false
2837 }
2838 if err := json.Unmarshal(tg, wtg); err != nil {
2839 log.Fatalf("Failed to unmarshal test groups JSON: %v", err)
2840 }
2834 testc.runTest(func() bool { 2841 testc.runTest(func() bool {
2835 wtg := testGroupFromAlgorithm(wtv.Algorithm, variant)
2836 if wtg == nil {
2837 log.Printf("INFO: Unknown test vector algorithm %q", wtv.Algorithm)
2838 return false
2839 }
2840
2841 if err := json.Unmarshal(testGroupJSON, wtg); err != nil {
2842 log.Fatalf("Failed to unmarshal test groups JSON: %v", err)
2843 }
2844 return wtg.run(wtv.Algorithm, variant) 2842 return wtg.run(wtv.Algorithm, variant)
2845 }) 2843 })
2846 } 2844 }