mirror of
https://github.com/json-iterator/go.git
synced 2025-03-29 21:20:52 +02:00
fix #196 do not hard code 1 << 49
This commit is contained in:
parent
d394a135a1
commit
3c0e5762c4
@ -127,10 +127,10 @@ func growOne(slice *sliceHeader, sliceType reflect.Type, elementType reflect.Typ
|
||||
newVal := reflect.MakeSlice(sliceType, newLen, newCap)
|
||||
dst := unsafe.Pointer(newVal.Pointer())
|
||||
// copy old array into new array
|
||||
originalBytesCount := uintptr(slice.Len) * elementType.Size()
|
||||
srcPtr := (*[1 << 49]byte)(slice.Data)
|
||||
dstPtr := (*[1 << 49]byte)(dst)
|
||||
copy(dstPtr[:originalBytesCount], srcPtr[:originalBytesCount])
|
||||
originalBytesCount := slice.Len * int(elementType.Size())
|
||||
srcSliceHeader := (unsafe.Pointer)(&sliceHeader{slice.Data, originalBytesCount, originalBytesCount})
|
||||
dstSliceHeader := (unsafe.Pointer)(&sliceHeader{dst, originalBytesCount, originalBytesCount})
|
||||
copy(*(*[]byte)(dstSliceHeader), *(*[]byte)(srcSliceHeader))
|
||||
slice.Data = dst
|
||||
slice.Len = newLen
|
||||
slice.Cap = newCap
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_write_empty_interface_via_placeholder(t *testing.T) {
|
||||
fmt.Println(^uint(0) >> 1)
|
||||
should := require.New(t)
|
||||
m := map[uint32]interface{}{1:"hello"}
|
||||
inf := reflect.ValueOf(m).MapIndex(reflect.ValueOf(uint32(1))).Interface()
|
||||
|
Loading…
x
Reference in New Issue
Block a user