mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/types: add comment about buffer reuse
This commit is contained in:
parent
6d445f41f3
commit
8e72579e7c
1 changed files with 4 additions and 3 deletions
|
|
@ -38,10 +38,11 @@ var encodeBufferPool = sync.Pool{
|
|||
New: func() interface{} { return new(bytes.Buffer) },
|
||||
}
|
||||
|
||||
// getPooledBuffer retrieves a buffer from the pool and creates a byte slice
|
||||
// of the requested size from it.
|
||||
// getPooledBuffer retrieves a buffer from the pool and creates a byte slice of the
|
||||
// requested size from it.
|
||||
//
|
||||
// The caller should return the Buffer object back into encodeBufferPool after use!
|
||||
// The caller should return the *bytes.Buffer object back into encodeBufferPool after use!
|
||||
// The returned byte slice must not be used after returning the buffer.
|
||||
func getPooledBuffer(size uint64) ([]byte, *bytes.Buffer, error) {
|
||||
if size > math.MaxInt {
|
||||
return nil, nil, fmt.Errorf("can't get buffer of size %d", size)
|
||||
|
|
|
|||
Loading…
Reference in a new issue