]> Cypherpunks repositories - gostls13.git/commitdiff
bufio: use bytes.Clone
authorcuiweixie <cuiweixie@gmail.com>
Tue, 27 Sep 2022 15:26:26 +0000 (23:26 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 27 Sep 2022 19:42:34 +0000 (19:42 +0000)
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>
src/bufio/bufio.go

index 1da8ffa951cc0db9a523e52d1deb39008e4523a6..5a88def0c75b5e7d5d2fe8f2d3b521519f018f7a 100644 (file)
@@ -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)
        }