removes/docker: 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
d7bc8694be
commit
710d22366d
@ -25,6 +25,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
refDocker "github.com/containerd/containerd/reference/docker"
|
||||
)
|
||||
@ -37,7 +38,7 @@ func FuzzFetcher(data []byte) int {
|
||||
|
||||
s := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Header().Set("content-range", fmt.Sprintf("bytes %d-%d/%d", 0, dataLen-1, dataLen))
|
||||
rw.Header().Set("content-length", fmt.Sprintf("%d", dataLen))
|
||||
rw.Header().Set("content-length", strconv.Itoa(dataLen))
|
||||
rw.Write(data)
|
||||
}))
|
||||
defer s.Close()
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -39,8 +40,8 @@ func TestFetcherOpen(t *testing.T) {
|
||||
if start > 0 {
|
||||
rw.Header().Set("content-range", fmt.Sprintf("bytes %d-127/128", start))
|
||||
}
|
||||
rw.Header().Set("content-length", fmt.Sprintf("%d", len(content[start:])))
|
||||
rw.Write(content[start:])
|
||||
rw.Header().Set("content-length", strconv.Itoa(len(content[start:])))
|
||||
_, _ = rw.Write(content[start:])
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user