forked from mirror/go-json
Improve decoder's memory footprint
This commit is contained in:
parent
a39bc30ed9
commit
397b667f34
|
@ -28,8 +28,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func unmarshal(data []byte, v interface{}) error {
|
func unmarshal(data []byte, v interface{}) error {
|
||||||
src := make([]byte, len(data)+1) // append nul byte to the end
|
src := append(data, nul) // append nul byte to the end
|
||||||
copy(src, data)
|
|
||||||
|
|
||||||
header := (*emptyInterface)(unsafe.Pointer(&v))
|
header := (*emptyInterface)(unsafe.Pointer(&v))
|
||||||
|
|
||||||
|
@ -47,8 +46,7 @@ func unmarshal(data []byte, v interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalNoEscape(data []byte, v interface{}) error {
|
func unmarshalNoEscape(data []byte, v interface{}) error {
|
||||||
src := make([]byte, len(data)+1) // append nul byte to the end
|
src := append(data, nul) // append nul byte to the end
|
||||||
copy(src, data)
|
|
||||||
|
|
||||||
header := (*emptyInterface)(unsafe.Pointer(&v))
|
header := (*emptyInterface)(unsafe.Pointer(&v))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue