1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-20 10:20:25 +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

@@ -91,6 +91,7 @@ func (pb *DataBuilder) Zstd() *DataBuilder {
if config.ShowDebugLog {
logrus.Debugln(file.Header(), strconv.FormatUint(ub.DAT.md5h8, 16), "data after zstd", file.ToLimitHexString(ub.Bytes(), 64))
}
data.ManualDestroy()
})
}
@@ -125,7 +126,9 @@ func (pb *DataBuilder) Seal(aead cipher.AEAD, teatyp uint8, additional uint16) *
data := algo.EncodeAEAD(aead, additional, b.Bytes())
ub.Reset()
data.V(func(b []byte) { ub.Write(b) })
data.ManualDestroy()
})
w.Destroy()
}))
}
@@ -139,6 +142,7 @@ func (pb *DataBuilder) Plain(teatyp uint8, additional uint16) *PacketBuilder {
ub.Reset()
_, _ = ub.ReadFrom(b)
})
w.Destroy()
}))
}
@@ -228,6 +232,11 @@ func (pb *PacketBuilder) Split(mtu int, nofrag bool) (pbs []PacketBytes) {
return
}
// Destroy call this once no one use it.
func (pb *PacketBuilder) Destroy() {
(*PacketItem)(pb).ManualDestroy()
}
func BuildPacketFromBytes(pb PacketBytes) pbuf.Bytes {
w := bin.SelectWriter()
pb.B(func(_ []byte, p *Packet) {