From 62d16ea3c562e91325511027c92a8032ac6392c5 Mon Sep 17 00:00:00 2001 From: tb Date: Mon, 6 Nov 2023 15:21:44 +0000 Subject: [PATCH] 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 --- .../lib/libcrypto/wycheproof/wycheproof.go | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/regress/lib/libcrypto/wycheproof/wycheproof.go b/regress/lib/libcrypto/wycheproof/wycheproof.go index feeb6c897ff..39f1456b67f 100644 --- a/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/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) }) } -- 2.20.1