mirror of https://github.com/golang/go.git
runtime: don't allocate a new string in printf
LGTM=dave R=rsc, dave CC=golang-codereviews https://golang.org/cl/139890043
This commit is contained in:
parent
6a76bca33f
commit
ef64d9ffcc
|
|
@ -39,7 +39,7 @@ func goprintf(s string) {
|
|||
// and type tables.
|
||||
//go:nosplit
|
||||
func printf(s *byte) {
|
||||
vprintf(gostring(s), add(unsafe.Pointer(&s), unsafe.Sizeof(s)))
|
||||
vprintf(gostringnocopy(s), add(unsafe.Pointer(&s), unsafe.Sizeof(s)))
|
||||
}
|
||||
|
||||
// sprintf is only called from C code.
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ runtime·gobytes(byte *p, intgo n)
|
|||
return sl;
|
||||
}
|
||||
|
||||
#pragma textflag NOSPLIT
|
||||
String
|
||||
runtime·gostringnocopy(byte *str)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ func noteclear(n *note)
|
|||
func lock(lk *mutex)
|
||||
func unlock(lk *mutex)
|
||||
func purgecachedstats(c *mcache)
|
||||
func gostringnocopy(b *byte) string
|
||||
|
||||
//go:noescape
|
||||
func write(fd uintptr, p unsafe.Pointer, n int32) int32
|
||||
|
|
|
|||
Loading…
Reference in New Issue