优化序列化方法

This commit is contained in:
hahwu 2026-02-26 14:10:13 +08:00
parent ba7065a6b9
commit 735504cf6b

View File

@ -234,8 +234,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 {