mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 22:24:02 +03:00
Use pool for frames
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package obfuscated2
|
||||
|
||||
import "sync"
|
||||
|
||||
var framePool sync.Pool
|
||||
|
||||
// MakeFrame returns new pointer to the handshake frame.
|
||||
func MakeFrame() *Frame {
|
||||
return framePool.Get().(*Frame)
|
||||
}
|
||||
|
||||
// ReturnFrame returns pointer to the handshake frame back to the pool.
|
||||
func ReturnFrame(f *Frame) {
|
||||
framePool.Put(f)
|
||||
}
|
||||
|
||||
func init() {
|
||||
framePool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
data := make(Frame, FrameLen)
|
||||
return &data
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user