Merge branch 'master' of github.com:goccy/go-json into feature/refactor-only-op

This commit is contained in:
Masaaki Goshima 2021-02-23 16:13:39 +09:00
commit e3acf4a01b
5 changed files with 1422 additions and 4362 deletions

19
CHANGELOG.md Normal file
View File

@ -0,0 +1,19 @@
# v0.4.7 - 2021/02/22
### Fix decoder
* Fix decoding of deep recursive structure
* Fix decoding of embedded unexported pointer field
* Fix invalid test case
* Fix decoding of invalid value
* Fix decoding of prefilled value
* Fix not being able to return UnmarshalTypeError when it should be returned
* Fix decoding of null value
* Fix decoding of type of null string
* Use pre allocated pointer if exists it at decoding
### Reduce memory usage at compile
* Integrate int/int8/int16/int32/int64 and uint/uint8/uint16/uint32/uint64 operation to reduce memory usage at compile
### Remove unnecessary optype

View File

@ -295,18 +295,11 @@ func (t opType) fieldToStringTagField() opType {
"StructEnd", "StructEnd",
} }
primitiveTypes := []string{ primitiveTypes := []string{
"int", "int8", "int16", "int32", "int64", "int", "uint", "float32", "float64", "bool", "string", "bytes",
"uint", "uint8", "uint16", "uint32", "uint64",
"float32", "float64", "bool", "string", "bytes",
"array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive", "array", "map", "mapLoad", "slice", "struct", "MarshalJSON", "MarshalText", "recursive",
"intString", "int8String", "int16String", "int32String", "int64String", "intString", "uintString",
"uintString", "uint8String", "uint16String", "uint32String", "uint64String", "intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr",
"intPtr", "int8Ptr", "int16Ptr", "int32Ptr", "int64Ptr", "intNPtr", "uintNPtr", "float32NPtr", "float64NPtr", "boolNPtr", "stringNPtr", "bytesNPtr",
"uintPtr", "uint8Ptr", "uint16Ptr", "uint32Ptr", "uint64Ptr",
"float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr",
"intNPtr", "int8NPtr", "int16NPtr", "int32NPtr", "int64NPtr",
"uintNPtr", "uint8NPtr", "uint16NPtr", "uint32NPtr", "uint64NPtr",
"float32NPtr", "float64NPtr", "boolNPtr", "stringNPtr", "bytesNPtr",
} }
primitiveTypesUpper := []string{} primitiveTypesUpper := []string{}
for _, typ := range primitiveTypes { for _, typ := range primitiveTypes {
@ -408,8 +401,7 @@ func (t opType) fieldToStringTagField() opType {
switch typ { switch typ {
case "", "Array", "Map", "MapLoad", "Slice", case "", "Array", "Map", "MapLoad", "Slice",
"Struct", "Recursive", "MarshalJSON", "MarshalText", "Struct", "Recursive", "MarshalJSON", "MarshalText",
"IntString", "Int8String", "Int16String", "Int32String", "Int64String", "IntString", "UintString":
"UintString", "Uint8String", "Uint16String", "Uint32String", "Uint64String":
return op return op
} }
return fmt.Sprintf( return fmt.Sprintf(

View File

@ -19,6 +19,8 @@ type opcode struct {
isTaggedKey bool // whether tagged key isTaggedKey bool // whether tagged key
anonymousKey bool // whether anonymous key anonymousKey bool // whether anonymous key
root bool // whether root root bool // whether root
rshiftNum uint8 // use to take bit for judging whether negative integer or not
mask uint64 // mask for number
indent int // indent number indent int // indent number
rshiftNum uint8 // use to take bit for judging whether negative integer or not rshiftNum uint8 // use to take bit for judging whether negative integer or not
mask uint64 // mask for number mask uint64 // mask for number

File diff suppressed because it is too large Load Diff

View File

@ -24,15 +24,6 @@ func store(base uintptr, idx uintptr, p uintptr) {
**(**uintptr)(unsafe.Pointer(&addr)) = p **(**uintptr)(unsafe.Pointer(&addr)) = p
} }
func ptrToInt(p uintptr) int { return **(**int)(unsafe.Pointer(&p)) }
func ptrToInt8(p uintptr) int8 { return **(**int8)(unsafe.Pointer(&p)) }
func ptrToInt16(p uintptr) int16 { return **(**int16)(unsafe.Pointer(&p)) }
func ptrToInt32(p uintptr) int32 { return **(**int32)(unsafe.Pointer(&p)) }
func ptrToInt64(p uintptr) int64 { return **(**int64)(unsafe.Pointer(&p)) }
func ptrToUint(p uintptr) uint { return **(**uint)(unsafe.Pointer(&p)) }
func ptrToUint8(p uintptr) uint8 { return **(**uint8)(unsafe.Pointer(&p)) }
func ptrToUint16(p uintptr) uint16 { return **(**uint16)(unsafe.Pointer(&p)) }
func ptrToUint32(p uintptr) uint32 { return **(**uint32)(unsafe.Pointer(&p)) }
func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) } func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) } func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }