优化序列化方法
This commit is contained in:
parent
36ab0e0d00
commit
72900b216c
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user