From bddecb1f8da1b8bc67c5ad14fa7e638f4a64dff5 Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 6 Nov 2023 15:21:44 +0000 Subject: 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 --- src/regress/lib/libcrypto/wycheproof/wycheproof.go | 20 +++++++++----------- 1 file 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 @@ -/* $OpenBSD: wycheproof.go,v 1.150 2023/11/06 15:17:02 tb Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.151 2023/11/06 15:21:44 tb Exp $ */ /* * Copyright (c) 2018 Joel Sing * Copyright (c) 2018,2019,2022 Theo Buehler @@ -2830,17 +2830,15 @@ func runTestVectors(path string, variant testVariant) bool { success := true for _, tg := range wtv.TestGroups { - testGroupJSON := tg + wtg := testGroupFromAlgorithm(wtv.Algorithm, variant) + if wtg == nil { + log.Printf("INFO: Unknown test vector algorithm %q", wtv.Algorithm) + return false + } + if err := json.Unmarshal(tg, wtg); err != nil { + log.Fatalf("Failed to unmarshal test groups JSON: %v", err) + } testc.runTest(func() bool { - wtg := testGroupFromAlgorithm(wtv.Algorithm, variant) - if wtg == nil { - log.Printf("INFO: Unknown test vector algorithm %q", wtv.Algorithm) - return false - } - - if err := json.Unmarshal(testGroupJSON, wtg); err != nil { - log.Fatalf("Failed to unmarshal test groups JSON: %v", err) - } return wtg.run(wtv.Algorithm, variant) }) } -- cgit v1.2.3-55-g6feb