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

@@ -55,11 +55,13 @@ func ParsePacketHeader(data []byte) (pbytes PacketBytes, err error) {
return
}
var crc uint64
pbuf.NewBytes(int(PacketHeadNoCRCLen)).V(func(b []byte) {
b := pbuf.NewBytes(int(PacketHeadNoCRCLen))
b.V(func(b []byte) {
copy(b, data[:PacketHeadNoCRCLen])
ClearTTL(b)
crc = algo.MD5Hash8(b)
})
b.ManualDestroy()
if crc != pb.DAT.md5h8 {
err = ErrBadCRCChecksum
if config.ShowDebugLog {
@@ -80,6 +82,7 @@ func ParsePacketHeader(data []byte) (pbytes PacketBytes, err error) {
pb.DAT.hashrem = int64(sz)
})
if err != nil {
p.ManualDestroy()
return
}
pbytes = pbuf.BufferItemToBytes(p)