From 7ace40ec22f23a9df78fdbee54fc44e6e30fb1dc Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 25 Jan 2024 04:18:36 +0700 Subject: encoding/json: realign struct UnmarshalTypeError and decodeState This reduce the UnmarshalTypeError size from 64 to 56 bytes (-8 bytes), and decodeState from 128 to 96 (-32 bytes). --- src/encoding/json/decode.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/encoding/json/decode.go') diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go index 59d4c7e734..c33b0ada8a 100644 --- a/src/encoding/json/decode.go +++ b/src/encoding/json/decode.go @@ -124,11 +124,11 @@ type Unmarshaler interface { // An UnmarshalTypeError describes a JSON value that was // not appropriate for a value of a specific Go type. type UnmarshalTypeError struct { - Value string // description of JSON value - "bool", "array", "number -5" Type reflect.Type // type of Go value it could not be assigned to - Offset int64 // error occurred after reading Offset bytes + Value string // description of JSON value - "bool", "array", "number -5" Struct string // name of the struct type containing the field Field string // the full path from root node to the field, include embedded struct + Offset int64 // error occurred after reading Offset bytes } func (e *UnmarshalTypeError) Error() string { @@ -210,12 +210,12 @@ type errorContext struct { // decodeState represents the state while decoding a JSON value. type decodeState struct { + scan scanner + savedError error + errorContext *errorContext data []byte off int // next read offset in data opcode int // last read result - scan scanner - errorContext *errorContext - savedError error useNumber bool disallowUnknownFields bool } -- cgit v1.3