mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 13:41:23 +08:00
9eb98e399d
Co-authored-by: goomada <madao@DESKTOP-IOEBS0C.localdomain>
19 lines
331 B
Go
19 lines
331 B
Go
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)
|
|
}
|