1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-23 12:00:34 +08:00

optimize(orbyte): use manual destroy

This commit is contained in:
源文雨
2025-04-04 01:26:37 +09:00
parent 82c6136782
commit b5992574ec
16 changed files with 83 additions and 28 deletions

View File

@@ -42,7 +42,7 @@ func (p *packet) pack() *net.Buffers {
return &net.Buffers{magicbuf, bin.NewWriterF(func(w *bin.Writer) {
w.WriteByte(byte(p.typ))
w.WriteUInt16(p.len)
}).Trans(), p.dat}
}), p.dat}
}
func (p *packet) Read(_ []byte) (int, error) {
@@ -80,7 +80,8 @@ func (p *packet) ReadFrom(r io.Reader) (n int64, err error) {
if err != nil {
return
}
p.dat = w.ToBytes().Trans()
p.dat = w.ToBytes().Copy().Trans()
w.Destroy()
return
}