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:
parent
5124683f24
commit
b67201557a
@ -142,7 +142,8 @@ func reuseSlice(slice *sliceHeader, sliceType reflect.Type, expectedCap int) {
|
|||||||
if expectedCap <= slice.Cap {
|
if expectedCap <= slice.Cap {
|
||||||
return
|
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.Cap = expectedCap
|
||||||
slice.Data = dst
|
slice.Data = dst
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user