replace some fmt.Sprintfs with strconv
Teeny-tiny optimizations: BenchmarkSprintf-10 37735996 32.31 ns/op 0 B/op 0 allocs/op BenchmarkItoa-10 591945836 2.031 ns/op 0 B/op 0 allocs/op BenchmarkFormatUint-10 593701444 2.014 ns/op 0 B/op 0 allocs/op Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
11a5dd8265
commit
b76cd4d9fd
@ -23,6 +23,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
@ -207,7 +208,7 @@ var usageCommand = cli.Command{
|
|||||||
var displaySize func(int64) string
|
var displaySize func(int64) string
|
||||||
if context.Bool("b") {
|
if context.Bool("b") {
|
||||||
displaySize = func(s int64) string {
|
displaySize = func(s int64) string {
|
||||||
return fmt.Sprintf("%d", s)
|
return strconv.FormatInt(s, 10)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displaySize = func(s int64) string {
|
displaySize = func(s int64) string {
|
||||||
|
@ -18,9 +18,9 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
@ -133,7 +133,7 @@ func TestDaemonCustomCgroup(t *testing.T) {
|
|||||||
t.Skip("skip TestDaemonCustomCgroup since no cgroup path available")
|
t.Skip("skip TestDaemonCustomCgroup since no cgroup path available")
|
||||||
}
|
}
|
||||||
|
|
||||||
customCgroup := fmt.Sprintf("%d", time.Now().Nanosecond())
|
customCgroup := strconv.Itoa(time.Now().Nanosecond())
|
||||||
configTOML := `
|
configTOML := `
|
||||||
version = 2
|
version = 2
|
||||||
[cgroup]
|
[cgroup]
|
||||||
|
@ -602,7 +602,7 @@ func (tc *nriTest) setup() {
|
|||||||
tc.prefix = strings.ToLower(tc.name)
|
tc.prefix = strings.ToLower(tc.name)
|
||||||
}
|
}
|
||||||
if tc.namespace == "" {
|
if tc.namespace == "" {
|
||||||
tc.namespace = tc.prefix + "-" + fmt.Sprintf("%d", os.Getpid())
|
tc.namespace = tc.prefix + "-" + strconv.Itoa(os.Getpid())
|
||||||
}
|
}
|
||||||
|
|
||||||
tc.sbCfg = make(map[string]*runtime.PodSandboxConfig)
|
tc.sbCfg = make(map[string]*runtime.PodSandboxConfig)
|
||||||
|
@ -151,7 +151,7 @@ func makeContainerName(c *runtime.ContainerMetadata, s *runtime.PodSandboxMetada
|
|||||||
s.Name, // 1: pod name
|
s.Name, // 1: pod name
|
||||||
s.Namespace, // 2: pod namespace
|
s.Namespace, // 2: pod namespace
|
||||||
s.Uid, // 3: pod uid
|
s.Uid, // 3: pod uid
|
||||||
strconv.FormatUint(uint64(s.Attempt), 10), // 4: attempt number of creating the container
|
strconv.FormatUint(uint64(c.Attempt), 10), // 4: attempt number of creating the container
|
||||||
}, nameDelimiter)
|
}, nameDelimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func makeContainerName(c *runtime.ContainerMetadata, s *runtime.PodSandboxMetada
|
|||||||
s.Name, // 1: pod name
|
s.Name, // 1: pod name
|
||||||
s.Namespace, // 2: pod namespace
|
s.Namespace, // 2: pod namespace
|
||||||
s.Uid, // 3: pod uid
|
s.Uid, // 3: pod uid
|
||||||
strconv.FormatUint(uint64(s.Attempt), 10), // 4: attempt number of creating the container
|
strconv.FormatUint(uint64(c.Attempt), 10), // 4: attempt number of creating the container
|
||||||
}, nameDelimiter)
|
}, nameDelimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user