/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/fs/buffer_pool.go
24 строки
636 B
Michael Mayer
Pkg: Add fs/README.md to document performance & security improvements
25 ноя 2025, 15:09
25 ноя 2025, 15:09
1631aec
Код
Авторство
О чём код?
package fs import "sync" // copyBufferSize defines the shared buffer length used for large file copies/hashes. const copyBufferSize = 256 * 1024 // copyBufferPool reuses byte slices to reduce allocations during file I/O. var copyBufferPool = sync.Pool{ //nolint:gochecknoglobals // shared pool for I/O buffers New: func() any { buf := make([]byte, copyBufferSize) return &buf }, } // getCopyBuffer returns a pooled buffer for copy operations. func getCopyBuffer() []byte { return *(copyBufferPool.Get().(*[]byte)) } // putCopyBuffer returns a buffer to the pool. func putCopyBuffer(buf []byte) { copyBufferPool.Put(&buf) }