mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +08:00
Move content encoding in the beginning of the middleware chain, update dependencies
This commit is contained in:
32
io/fs/mem.go
32
io/fs/mem.go
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/datarhei/core/v16/glob"
|
||||
"github.com/datarhei/core/v16/log"
|
||||
"github.com/datarhei/core/v16/mem"
|
||||
)
|
||||
|
||||
// MemConfig is the config that is required for creating
|
||||
@@ -126,37 +127,10 @@ func (f *memFile) free() {
|
||||
f.data = nil
|
||||
}
|
||||
|
||||
type fileDataPool struct {
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
var pool *fileDataPool = nil
|
||||
|
||||
func NewFileDataPool() *fileDataPool {
|
||||
p := &fileDataPool{
|
||||
pool: sync.Pool{
|
||||
New: func() any {
|
||||
return &bytes.Buffer{}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *fileDataPool) Get() *bytes.Buffer {
|
||||
buf := p.pool.Get().(*bytes.Buffer)
|
||||
buf.Reset()
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (p *fileDataPool) Put(buf *bytes.Buffer) {
|
||||
p.pool.Put(buf)
|
||||
}
|
||||
var pool *mem.BufferPool = nil
|
||||
|
||||
func init() {
|
||||
pool = NewFileDataPool()
|
||||
pool = mem.NewBufferPool()
|
||||
}
|
||||
|
||||
type memFilesystem struct {
|
||||
|
Reference in New Issue
Block a user