1
0
mirror of https://github.com/json-iterator/go.git synced 2025-02-01 19:14:29 +02:00

try to fix #194 with larger array

This commit is contained in:
Tao Wen 2017-11-11 08:31:44 +08:00
parent b1b003864e
commit 9fddff05f0
3 changed files with 5 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea
/coverage.txt
/profile.out
/bug_test.go

View File

@ -168,7 +168,7 @@ func (iter *Iterator) isObjectEnd() bool {
if c == '}' {
return true
}
iter.ReportError("isObjectEnd", "object ended prematurely")
iter.ReportError("isObjectEnd", "object ended prematurely, unexpected char " + string([]byte{c}))
return true
}

View File

@ -128,11 +128,9 @@ func growOne(slice *sliceHeader, sliceType reflect.Type, elementType reflect.Typ
dst := unsafe.Pointer(newVal.Pointer())
// copy old array into new array
originalBytesCount := uintptr(slice.Len) * elementType.Size()
srcPtr := (*[1 << 30]byte)(slice.Data)
dstPtr := (*[1 << 30]byte)(dst)
for i := uintptr(0); i < originalBytesCount; i++ {
dstPtr[i] = srcPtr[i]
}
srcPtr := (*[1 << 49]byte)(slice.Data)
dstPtr := (*[1 << 49]byte)(dst)
copy(dstPtr[:originalBytesCount], srcPtr[:originalBytesCount])
slice.Data = dst
slice.Len = newLen
slice.Cap = newCap