1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-22 03:20:30 +08:00

optimize: memory consumption

This commit is contained in:
源文雨
2025-05-13 00:59:05 +09:00
parent d65fc4dd71
commit df8f6affa3
19 changed files with 204 additions and 242 deletions

View File

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