mirror of https://github.com/docker/cli.git
replace some basic uses of fmt.Sprintf()
Really tiny gains here, and doesn't significantly impact readability: BenchmarkSprintf BenchmarkSprintf-10 11528700 91.59 ns/op 32 B/op 1 allocs/op BenchmarkConcat BenchmarkConcat-10 100000000 11.76 ns/op 0 B/op 0 allocs/op Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
8aee745ab2
commit
f4bde68694
|
@ -103,7 +103,7 @@ func (c *configContext) Labels() string {
|
|||
}
|
||||
var joinLabels []string
|
||||
for k, v := range mapLabels {
|
||||
joinLabels = append(joinLabels, fmt.Sprintf("%s=%s", k, v))
|
||||
joinLabels = append(joinLabels, k+"="+v)
|
||||
}
|
||||
return strings.Join(joinLabels, ",")
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, options *createOptio
|
|||
if v == nil {
|
||||
newEnv = append(newEnv, k)
|
||||
} else {
|
||||
newEnv = append(newEnv, fmt.Sprintf("%s=%s", k, *v))
|
||||
newEnv = append(newEnv, k+"="+*v)
|
||||
}
|
||||
}
|
||||
copts.env = *opts.NewListOptsRef(&newEnv, nil)
|
||||
|
|
|
@ -101,7 +101,7 @@ func runRun(dockerCli command.Cli, flags *pflag.FlagSet, ropts *runOptions, copt
|
|||
if v == nil {
|
||||
newEnv = append(newEnv, k)
|
||||
} else {
|
||||
newEnv = append(newEnv, fmt.Sprintf("%s=%s", k, *v))
|
||||
newEnv = append(newEnv, k+"="+*v)
|
||||
}
|
||||
}
|
||||
copts.env = *opts.NewListOptsRef(&newEnv, nil)
|
||||
|
|
|
@ -247,7 +247,7 @@ func (c *ContainerContext) Labels() string {
|
|||
|
||||
var joinLabels []string
|
||||
for k, v := range c.c.Labels {
|
||||
joinLabels = append(joinLabels, fmt.Sprintf("%s=%s", k, v))
|
||||
joinLabels = append(joinLabels, k+"="+v)
|
||||
}
|
||||
return strings.Join(joinLabels, ",")
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ func (c *networkContext) Labels() string {
|
|||
|
||||
var joinLabels []string
|
||||
for k, v := range c.n.Labels {
|
||||
joinLabels = append(joinLabels, fmt.Sprintf("%s=%s", k, v))
|
||||
joinLabels = append(joinLabels, k+"="+v)
|
||||
}
|
||||
return strings.Join(joinLabels, ",")
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ func (c *secretContext) Labels() string {
|
|||
}
|
||||
var joinLabels []string
|
||||
for k, v := range mapLabels {
|
||||
joinLabels = append(joinLabels, fmt.Sprintf("%s=%s", k, v))
|
||||
joinLabels = append(joinLabels, k+"="+v)
|
||||
}
|
||||
return strings.Join(joinLabels, ",")
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ func prettyPrintEvent(out io.Writer, event eventtypes.Message) error {
|
|||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
v := event.Actor.Attributes[k]
|
||||
attrs = append(attrs, fmt.Sprintf("%s=%s", k, v))
|
||||
attrs = append(attrs, k+"="+v)
|
||||
}
|
||||
fmt.Fprintf(out, " (%s)", strings.Join(attrs, ", "))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package convert
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -605,7 +604,7 @@ func convertEnvironment(source map[string]*string) []string {
|
|||
case nil:
|
||||
output = append(output, name)
|
||||
default:
|
||||
output = append(output, fmt.Sprintf("%s=%s", name, *value))
|
||||
output = append(output, name+"="+*value)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue