Co-authored-by: goomada <madao@DESKTOP-IOEBS0C.localdomain>
This commit is contained in:
18
component/ssr/tools/bufPool.go
Normal file
18
component/ssr/tools/bufPool.go
Normal file
@ -0,0 +1,18 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/rand"
|
||||
"sync"
|
||||
|
||||
"github.com/Dreamacro/clash/common/pool"
|
||||
)
|
||||
|
||||
var BufPool = sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}
|
||||
|
||||
func AppendRandBytes(b *bytes.Buffer, length int) {
|
||||
randBytes := pool.Get(length)
|
||||
defer pool.Put(randBytes)
|
||||
rand.Read(randBytes)
|
||||
b.Write(randBytes)
|
||||
}
|
Reference in New Issue
Block a user