Small refactoring (#4)

* Move some methods to pool.go

* Use method instead of manual resetting of buffer

* Fix typo
This commit is contained in:
Albert
2016-06-29 00:46:18 +05:00
committed by Aliaksandr Valialkin
parent a3c01bbe26
commit bf51c4698b
2 changed files with 16 additions and 20 deletions
-19
View File
@@ -57,22 +57,3 @@ func (b *ByteBuffer) SetString(s string) {
func (b *ByteBuffer) Reset() {
b.B = b.B[:0]
}
// Get returns an empty byte buffer from the pool.
//
// Getd byte buffer may be returned to the pool via Put call.
// This reduces the number of memory allocations required for byte buffer
// management.
func Get() *ByteBuffer {
return defaultPool.Get()
}
// Put returns byte buffer to the pool.
//
// ByteBuffer.B mustn't be touched after returning it to the pool.
// Otherwise data races will occur.
func Put(b *ByteBuffer) {
defaultPool.Put(b)
}
var defaultPool Pool