mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes: don't grow Buffer if capacity is available
Also added a new benchmark from the same test: benchmark old ns/op new ns/op delta BenchmarkBufferNotEmptyWriteRead 2643698 709189 -73.17% Fixes #5154 R=golang-dev, r, gri CC=golang-dev https://golang.org/cl/8164043
This commit is contained in:
parent
fb3ed166e3
commit
994f59666f
3 changed files with 41 additions and 0 deletions
|
|
@ -7,3 +7,7 @@ package bytes
|
|||
// Export func for testing
|
||||
var IndexBytePortable = indexBytePortable
|
||||
var EqualPortable = equalPortable
|
||||
|
||||
func (b *Buffer) Cap() int {
|
||||
return cap(b.buf)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue