Codebase list golang-gopkg-alexcesaro-quotedprintable.v3 / a26d90b6-4bed-4d9c-9bc5-86fd2f360be3/upstream/0.0_git20150716.1.2caba25 pool.go
a26d90b6-4bed-4d9c-9bc5-86fd2f360be3/upstream/0.0_git20150716.1.2caba25

Tree @a26d90b6-4bed-4d9c-9bc5-86fd2f360be3/upstream/0.0_git20150716.1.2caba25 (Download .tar.gz)

pool.go @a26d90b6-4bed-4d9c-9bc5-86fd2f360be3/upstream/0.0_git20150716.1.2caba25raw · history · blame

// +build go1.3

package quotedprintable

import (
	"bytes"
	"sync"
)

var bufPool = sync.Pool{
	New: func() interface{} {
		return new(bytes.Buffer)
	},
}

func getBuffer() *bytes.Buffer {
	return bufPool.Get().(*bytes.Buffer)
}

func putBuffer(buf *bytes.Buffer) {
	if buf.Len() > 1024 {
		return
	}
	buf.Reset()
	bufPool.Put(buf)
}