Skip to content

Commit

Permalink
build: toControllerOptions: micro-optimization
Browse files Browse the repository at this point in the history
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 <github@gone.nl>
  • Loading branch information
thaJeztah committed Jun 23, 2023
1 parent bd672ea commit 8ec437d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,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
}
}
Expand Down

0 comments on commit 8ec437d

Please sign in to comment.