1
0
mirror of https://github.com/json-iterator/go.git synced 2025-05-16 21:45:43 +02:00

avoid gc issue

This commit is contained in:
Tao Wen 2017-08-01 08:34:38 +08:00
parent 5124683f24
commit b67201557a

View File

@ -142,7 +142,8 @@ func reuseSlice(slice *sliceHeader, sliceType reflect.Type, expectedCap int) {
if expectedCap <= slice.Cap {
return
}
dst := unsafe.Pointer(reflect.MakeSlice(sliceType, 0, expectedCap).Pointer())
newVal := reflect.MakeSlice(sliceType, 0, expectedCap)
dst := unsafe.Pointer(newVal.Pointer())
slice.Cap = expectedCap
slice.Data = dst
}