github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/core/buffer_pool.go (about)

     1  package core
     2  
     3  import (
     4  	"bytes"
     5  	"sync"
     6  )
     7  
     8  var textBufferPool = sync.Pool{
     9  	New: func() interface{} {
    10  		return bytes.NewBuffer(make([]byte, 0, 4<<10)) // 4KB
    11  	},
    12  }
    13  
    14  var mediaBufferPool = sync.Pool{
    15  	New: func() interface{} {
    16  		return bytes.NewBuffer(make([]byte, 0, 10<<20)) // 10MB
    17  	},
    18  }