From 7c8967631117b242d80bb3f1c017dd8dc81d3f5c Mon Sep 17 00:00:00 2001 From: Rado M Date: Mon, 20 Nov 2023 15:36:41 +0200 Subject: [PATCH] refactor: reuse OptLevel() to get the opt level --- builder/build.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/builder/build.go b/builder/build.go index 339307674b..5fc6f44ee9 100644 --- a/builder/build.go +++ b/builder/build.go @@ -807,21 +807,8 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe // Run wasm-opt for wasm binaries if arch := strings.Split(config.Triple(), "-")[0]; arch == "wasm32" { - var opt string - switch config.Options.Opt { - case "none", "0": - opt = "-O0" - case "1": - opt = "-O1" - case "2": - opt = "-O2" - case "s": - opt = "-Os" - case "z": - opt = "-Oz" - default: - return fmt.Errorf("unknown opt level: %q", config.Options.Opt) - } + optLevel, _, _ := config.OptLevel() + opt := "-" + optLevel var args []string