diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-09-27 23:26:26 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-27 19:42:34 +0000 |
| commit | 86ca550f407827f620e6c8314ec503fdb48dd898 (patch) | |
| tree | 1e1a3e933e7d548b53a1631a49ef2031c5ea2712 /src/bufio | |
| parent | bf5805eae436a1ddbad593ec0671c9a7e8c67a9a (diff) | |
| download | go-86ca550f407827f620e6c8314ec503fdb48dd898.tar.xz | |
bufio: use bytes.Clone
Change-Id: Ic21d979da8be1a6047b9bcd65b5ee71ca2ef7548
Reviewed-on: https://go-review.googlesource.com/c/go/+/435278
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/bufio')
| -rw-r--r-- | src/bufio/bufio.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/bufio/bufio.go b/src/bufio/bufio.go index 1da8ffa951..5a88def0c7 100644 --- a/src/bufio/bufio.go +++ b/src/bufio/bufio.go @@ -454,8 +454,7 @@ func (b *Reader) collectFragments(delim byte) (fullBuffers [][]byte, finalFragme } // Make a copy of the buffer. - buf := make([]byte, len(frag)) - copy(buf, frag) + buf := bytes.Clone(frag) fullBuffers = append(fullBuffers, buf) totalLen += len(buf) } |
