-
Dmitry Vyukov authored
Consider the following code: s := "(" + string(byteSlice) + ")" Currently we allocate a new string during []byte->string conversion, and pass it to concatstrings. String allocation is unnecessary in this case, because concatstrings does memorize the strings for later use. This change uses slicebytetostringtmp to construct temp string directly from []byte buffer and passes it to concatstrings. I've found few such cases in std lib: s += string(msg[off:off+c]) + "." buf.WriteString("Sec-WebSocket-Accept: " + string(c.accept) + "\r\n") bw.WriteString("Sec-WebSocket-Key: " + string(nonce) + "\r\n") err = xml.Unmarshal([]byte("<Top>"+string(data)+"</Top>"), &logStruct) d.err = d.syntaxError("invalid XML name: " + string(b)) return m, ProtocolError("malformed MIME header line: " + string(kv)) But there are much more in our internal code base. Change-Id: I42f401f317131237ddd0cb9786b0940213af16fb Reviewed-on: https://go-review.googlesource.com/3163Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
205ae07c