Skip to content
Snippets Groups Projects
buffers.go 442 B
Newer Older
  • Learn to ignore specific revisions
  • Konrad Zemek's avatar
    Konrad Zemek committed
    // Copyright 2019 Path Network, Inc. All rights reserved.
    // Use of this source code is governed by a BSD-style
    // license that can be found in the LICENSE file.
    
    package main
    
    import (
    	"math"
    	"sync"
    )
    
    var buffers sync.Pool
    
    func init() {
    
    	buffers.New = func() any { return make([]byte, math.MaxUint16) }
    
    Konrad Zemek's avatar
    Konrad Zemek committed
    }
    
    func GetBuffer() []byte {
    	return buffers.Get().([]byte)
    }
    
    func PutBuffer(buf []byte) {
    
    	buffers.Put(buf) // nolint:staticcheck
    
    Konrad Zemek's avatar
    Konrad Zemek committed
    }