File: pool.go

package info (click to toggle)
golang-gopkg-alexcesaro-quotedprintable.v3 0.0~git20150716.0.2caba25-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 116 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 335 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// +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)
}