From 90554be0302a62f1a2f0cbd6c6c269a3cdc747bc Mon Sep 17 00:00:00 2001 From: Cristian Staretu Date: Wed, 1 Apr 2015 18:59:51 +0300 Subject: bytes: export Cap method for buffer Obtaining the actual size of the underlying storage of the buffer can be very useful in various scenarios. Long running programs which write and read large amounts of data to buffers might have to recycle buffers in order to avoid holding onto potentially huge buffers. For example, a piece of code which buffers a lot of data in a buffer might need to release the big buffer and start again with a smaller buffer after it finished processing the huge amount of data. In cases where pools of bytes.Buffer are used, being able to check the size of the allocated data can be very useful. Instead of forking bytes.Buffer or writing new code, we can export the Cap() method. Change-Id: I79d4f0a3cff53b9419d82c8122964761e9e38566 Reviewed-on: https://go-review.googlesource.com/8342 Reviewed-by: Rob Pike --- src/bytes/export_test.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/bytes/export_test.go') diff --git a/src/bytes/export_test.go b/src/bytes/export_test.go index 3b915d5ead..f61523e60b 100644 --- a/src/bytes/export_test.go +++ b/src/bytes/export_test.go @@ -7,7 +7,3 @@ package bytes // Export func for testing var IndexBytePortable = indexBytePortable var EqualPortable = equalPortable - -func (b *Buffer) Cap() int { - return cap(b.buf) -} -- cgit v1.3-5-g9baa