github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/gopkg.in/alexcesaro/quotedprintable.v3/pool.go (about)

     1  // +build go1.3
     2  
     3  package quotedprintable
     4  
     5  import (
     6  	"bytes"
     7  	"sync"
     8  )
     9  
    10  var bufPool = sync.Pool{
    11  	New: func() interface{} {
    12  		return new(bytes.Buffer)
    13  	},
    14  }
    15  
    16  func getBuffer() *bytes.Buffer {
    17  	return bufPool.Get().(*bytes.Buffer)
    18  }
    19  
    20  func putBuffer(buf *bytes.Buffer) {
    21  	if buf.Len() > 1024 {
    22  		return
    23  	}
    24  	buf.Reset()
    25  	bufPool.Put(buf)
    26  }