mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
A bytes.Buffer only has one embedded slice these days.
parent
46e9dc31e2
commit
99bf2690f9
@ -96,8 +96,7 @@ parent trace, etc.
|
|||||||
## Copying
|
## Copying
|
||||||
|
|
||||||
To avoid unexpected aliasing, be careful when copying a struct from another package.
|
To avoid unexpected aliasing, be careful when copying a struct from another package.
|
||||||
For example, the bytes.Buffer type contains a `[]byte` slice and, as an optimization
|
For example, the bytes.Buffer type contains a `[]byte` slice. If you copy a `Buffer`,
|
||||||
for small strings, a small byte array to which the slice may refer. If you copy a `Buffer`,
|
|
||||||
the slice in the copy may alias the array in the original, causing subsequent method
|
the slice in the copy may alias the array in the original, causing subsequent method
|
||||||
calls to have surprising effects.
|
calls to have surprising effects.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user