优化序列化方法

This commit is contained in:
hahwu 2026-02-26 14:10:13 +08:00
parent b7472d7ab3
commit 3de1b738a3

View File

@ -238,8 +238,10 @@ func GobMarshal(data interface{}) ([]byte, error) {
bufferPool.Put(buf) // 即使出错也要归还
return nil, err
}
result := make([]byte, buf.Len())
copy(result, buf.Bytes())
bufferPool.Put(buf) // 归还到对象池
return buf.Bytes(), nil
return result, nil
}
func GobUnmarshal(data []byte, obj interface{}) error {