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