diff options
author | tb <> | 2023-11-06 15:21:44 +0000 |
---|---|---|
committer | tb <> | 2023-11-06 15:21:44 +0000 |
commit | bddecb1f8da1b8bc67c5ad14fa7e638f4a64dff5 (patch) | |
tree | 2725899380fcff86d14b7c9a0115a86afdf1c84b | |
parent | 59fa23f90a8faf4520e9a24019a3c71c2d81a9e1 (diff) | |
download | openbsd-bddecb1f8da1b8bc67c5ad14fa7e638f4a64dff5.tar.gz openbsd-bddecb1f8da1b8bc67c5ad14fa7e638f4a64dff5.tar.bz2 openbsd-bddecb1f8da1b8bc67c5ad14fa7e638f4a64dff5.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
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 20 |
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 | } |