1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-23 11:37:32 +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 .idea
/coverage.txt /coverage.txt
/profile.out /profile.out
/bug_test.go

View File

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

View File

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