From a4da7661ff8c2b4d74912dbf5ebae4b84092e611 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Jun 2023 12:36:37 +0200 Subject: [PATCH] build: toControllerOptions: micro-optimization Swapping the order of these checks, which I guess is the most minimal optimization possible BenchmarkGetEnv-10 68764720 16.82 ns/op 0 B/op 0 allocs/op BenchmarkMap-10 454135184 2.635 ns/op 0 B/op 0 allocs/op Signed-off-by: Sebastiaan van Stijn --- commands/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/build.go b/commands/build.go index c945b38f..8945d2fd 100644 --- a/commands/build.go +++ b/commands/build.go @@ -145,8 +145,8 @@ func (o *buildOptions) toControllerOptions() (*controllerapi.BuildOptions, error } // TODO: extract env var parsing to a method easily usable by library consumers - if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" { - if _, ok := opts.BuildArgs["SOURCE_DATE_EPOCH"]; !ok { + if _, ok := opts.BuildArgs["SOURCE_DATE_EPOCH"]; !ok { + if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" { opts.BuildArgs["SOURCE_DATE_EPOCH"] = v } }