net/textproto: use bytes.Clone

Change-Id: Ic73d667a98df3f2d1705a67e7e8625c6ba65cc0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/435284
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
cuiweixie 2022-09-28 00:31:44 +08:00 committed by Gopher Robot
parent a59e614aa1
commit acc5e3a0c2

View file

@ -42,9 +42,7 @@ func (r *Reader) ReadLine() (string, error) {
func (r *Reader) ReadLineBytes() ([]byte, error) {
line, err := r.readLineSlice()
if line != nil {
buf := make([]byte, len(line))
copy(buf, line)
line = buf
line = bytes.Clone(line)
}
return line, err
}
@ -111,9 +109,7 @@ func trim(s []byte) []byte {
func (r *Reader) ReadContinuedLineBytes() ([]byte, error) {
line, err := r.readContinuedLineSlice(noValidation)
if line != nil {
buf := make([]byte, len(line))
copy(buf, line)
line = buf
line = bytes.Clone(line)
}
return line, err
}