pool.go 320 B

123456789101112131415161718192021222324
  1. //go:build !confonly
  2. // +build !confonly
  3. package quic
  4. import (
  5. "sync"
  6. "github.com/v2fly/v2ray-core/v4/common/bytespool"
  7. )
  8. var pool *sync.Pool
  9. func init() {
  10. pool = bytespool.GetPool(2048)
  11. }
  12. func getBuffer() []byte {
  13. return pool.Get().([]byte)
  14. }
  15. func putBuffer(p []byte) {
  16. pool.Put(p) // nolint: staticcheck
  17. }