From: tb Date: Mon, 6 Nov 2023 15:21:44 +0000 (+0000) Subject: Pull everything except the actual run call out of the closure X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=62d16ea3c562e91325511027c92a8032ac6392c5;p=openbsd 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 --- 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) }) }