mirror of https://github.com/goccy/go-json.git
Switch to lazy init() in decoder and encoder
This will prevent go-json from consuming heap unless it is used.
This commit is contained in:
parent
3e9769d637
commit
f14426c40f
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unicode"
|
||||
"unsafe"
|
||||
|
@ -17,22 +18,27 @@ var (
|
|||
typeAddr *runtime.TypeAddr
|
||||
cachedDecoderMap unsafe.Pointer // map[uintptr]decoder
|
||||
cachedDecoder []Decoder
|
||||
initOnce sync.Once
|
||||
)
|
||||
|
||||
func init() {
|
||||
typeAddr = runtime.AnalyzeTypeAddr()
|
||||
if typeAddr == nil {
|
||||
typeAddr = &runtime.TypeAddr{}
|
||||
}
|
||||
cachedDecoder = make([]Decoder, typeAddr.AddrRange>>typeAddr.AddrShift+1)
|
||||
func initDecoder() {
|
||||
initOnce.Do(func() {
|
||||
typeAddr = runtime.AnalyzeTypeAddr()
|
||||
if typeAddr == nil {
|
||||
typeAddr = &runtime.TypeAddr{}
|
||||
}
|
||||
cachedDecoder = make([]Decoder, typeAddr.AddrRange>>typeAddr.AddrShift+1)
|
||||
})
|
||||
}
|
||||
|
||||
func loadDecoderMap() map[uintptr]Decoder {
|
||||
initDecoder()
|
||||
p := atomic.LoadPointer(&cachedDecoderMap)
|
||||
return *(*map[uintptr]Decoder)(unsafe.Pointer(&p))
|
||||
}
|
||||
|
||||
func storeDecoder(typ uintptr, dec Decoder, m map[uintptr]Decoder) {
|
||||
initDecoder()
|
||||
newDecoderMap := make(map[uintptr]Decoder, len(m)+1)
|
||||
newDecoderMap[typ] = dec
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) {
|
||||
initDecoder()
|
||||
typeptr := uintptr(unsafe.Pointer(typ))
|
||||
if typeptr > typeAddr.MaxTypeAddr {
|
||||
return compileToGetDecoderSlowPath(typeptr, typ)
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
var decMu sync.RWMutex
|
||||
|
||||
func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) {
|
||||
initDecoder()
|
||||
typeptr := uintptr(unsafe.Pointer(typ))
|
||||
if typeptr > typeAddr.MaxTypeAddr {
|
||||
return compileToGetDecoderSlowPath(typeptr, typ)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
||||
|
@ -24,14 +25,17 @@ var (
|
|||
cachedOpcodeSets []*OpcodeSet
|
||||
cachedOpcodeMap unsafe.Pointer // map[uintptr]*OpcodeSet
|
||||
typeAddr *runtime.TypeAddr
|
||||
initEncoderOnce sync.Once
|
||||
)
|
||||
|
||||
func init() {
|
||||
typeAddr = runtime.AnalyzeTypeAddr()
|
||||
if typeAddr == nil {
|
||||
typeAddr = &runtime.TypeAddr{}
|
||||
}
|
||||
cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange>>typeAddr.AddrShift+1)
|
||||
func initEncoder() {
|
||||
initEncoderOnce.Do(func() {
|
||||
typeAddr = runtime.AnalyzeTypeAddr()
|
||||
if typeAddr == nil {
|
||||
typeAddr = &runtime.TypeAddr{}
|
||||
}
|
||||
cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange>>typeAddr.AddrShift+1)
|
||||
})
|
||||
}
|
||||
|
||||
func loadOpcodeMap() map[uintptr]*OpcodeSet {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package encoder
|
||||
|
||||
func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) {
|
||||
initEncoder()
|
||||
if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {
|
||||
codeSet, err := compileToGetCodeSetSlowPath(typeptr)
|
||||
if err != nil {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
var setsMu sync.RWMutex
|
||||
|
||||
func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) {
|
||||
initEncoder()
|
||||
if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {
|
||||
codeSet, err := compileToGetCodeSetSlowPath(typeptr)
|
||||
if err != nil {
|
||||
|
|
|
@ -25,59 +25,70 @@
|
|||
package encoder
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var endianness int
|
||||
var (
|
||||
endianness int
|
||||
initIntOnce sync.Once
|
||||
intLELookup *[100]uint16
|
||||
intBELookup *[100]uint16
|
||||
intLookup [2]*[100]uint16
|
||||
)
|
||||
|
||||
func init() {
|
||||
var b [2]byte
|
||||
*(*uint16)(unsafe.Pointer(&b)) = uint16(0xABCD)
|
||||
func initInt() {
|
||||
initIntOnce.Do(func() {
|
||||
var b [2]byte
|
||||
*(*uint16)(unsafe.Pointer(&b)) = uint16(0xABCD)
|
||||
|
||||
switch b[0] {
|
||||
case 0xCD:
|
||||
endianness = 0 // LE
|
||||
case 0xAB:
|
||||
endianness = 1 // BE
|
||||
default:
|
||||
panic("could not determine endianness")
|
||||
}
|
||||
switch b[0] {
|
||||
case 0xCD:
|
||||
endianness = 0 // LE
|
||||
case 0xAB:
|
||||
endianness = 1 // BE
|
||||
default:
|
||||
panic("could not determine endianness")
|
||||
}
|
||||
|
||||
// "00010203...96979899" cast to []uint16
|
||||
intLELookup = &[100]uint16{
|
||||
0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, 0x3930,
|
||||
0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731, 0x3831, 0x3931,
|
||||
0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732, 0x3832, 0x3932,
|
||||
0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733, 0x3833, 0x3933,
|
||||
0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734, 0x3834, 0x3934,
|
||||
0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735, 0x3835, 0x3935,
|
||||
0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736, 0x3836, 0x3936,
|
||||
0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737, 0x3837, 0x3937,
|
||||
0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738, 0x3838, 0x3938,
|
||||
0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739, 0x3839, 0x3939,
|
||||
}
|
||||
|
||||
intBELookup = &[100]uint16{
|
||||
0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036, 0x3037, 0x3038, 0x3039,
|
||||
0x3130, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, 0x3139,
|
||||
0x3230, 0x3231, 0x3232, 0x3233, 0x3234, 0x3235, 0x3236, 0x3237, 0x3238, 0x3239,
|
||||
0x3330, 0x3331, 0x3332, 0x3333, 0x3334, 0x3335, 0x3336, 0x3337, 0x3338, 0x3339,
|
||||
0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436, 0x3437, 0x3438, 0x3439,
|
||||
0x3530, 0x3531, 0x3532, 0x3533, 0x3534, 0x3535, 0x3536, 0x3537, 0x3538, 0x3539,
|
||||
0x3630, 0x3631, 0x3632, 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639,
|
||||
0x3730, 0x3731, 0x3732, 0x3733, 0x3734, 0x3735, 0x3736, 0x3737, 0x3738, 0x3739,
|
||||
0x3830, 0x3831, 0x3832, 0x3833, 0x3834, 0x3835, 0x3836, 0x3837, 0x3838, 0x3839,
|
||||
0x3930, 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, 0x3937, 0x3938, 0x3939,
|
||||
}
|
||||
|
||||
intLookup = [2]*[100]uint16{intLELookup, intBELookup}
|
||||
})
|
||||
}
|
||||
|
||||
// "00010203...96979899" cast to []uint16
|
||||
var intLELookup = [100]uint16{
|
||||
0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, 0x3930,
|
||||
0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731, 0x3831, 0x3931,
|
||||
0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732, 0x3832, 0x3932,
|
||||
0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733, 0x3833, 0x3933,
|
||||
0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734, 0x3834, 0x3934,
|
||||
0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735, 0x3835, 0x3935,
|
||||
0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736, 0x3836, 0x3936,
|
||||
0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737, 0x3837, 0x3937,
|
||||
0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738, 0x3838, 0x3938,
|
||||
0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739, 0x3839, 0x3939,
|
||||
}
|
||||
|
||||
var intBELookup = [100]uint16{
|
||||
0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036, 0x3037, 0x3038, 0x3039,
|
||||
0x3130, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, 0x3139,
|
||||
0x3230, 0x3231, 0x3232, 0x3233, 0x3234, 0x3235, 0x3236, 0x3237, 0x3238, 0x3239,
|
||||
0x3330, 0x3331, 0x3332, 0x3333, 0x3334, 0x3335, 0x3336, 0x3337, 0x3338, 0x3339,
|
||||
0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436, 0x3437, 0x3438, 0x3439,
|
||||
0x3530, 0x3531, 0x3532, 0x3533, 0x3534, 0x3535, 0x3536, 0x3537, 0x3538, 0x3539,
|
||||
0x3630, 0x3631, 0x3632, 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639,
|
||||
0x3730, 0x3731, 0x3732, 0x3733, 0x3734, 0x3735, 0x3736, 0x3737, 0x3738, 0x3739,
|
||||
0x3830, 0x3831, 0x3832, 0x3833, 0x3834, 0x3835, 0x3836, 0x3837, 0x3838, 0x3839,
|
||||
0x3930, 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, 0x3937, 0x3938, 0x3939,
|
||||
}
|
||||
|
||||
var intLookup = [2]*[100]uint16{&intLELookup, &intBELookup}
|
||||
|
||||
func numMask(numBitSize uint8) uint64 {
|
||||
return 1<<numBitSize - 1
|
||||
}
|
||||
|
||||
func AppendInt(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte {
|
||||
initInt() // lazy init
|
||||
|
||||
var u64 uint64
|
||||
switch code.NumBitSize {
|
||||
case 8:
|
||||
|
@ -132,6 +143,8 @@ func AppendInt(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte {
|
|||
}
|
||||
|
||||
func AppendUint(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte {
|
||||
initInt() // lazy init
|
||||
|
||||
var u64 uint64
|
||||
switch code.NumBitSize {
|
||||
case 8:
|
||||
|
|
|
@ -3,6 +3,7 @@ package encoder
|
|||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type CodeType int
|
||||
|
@ -22,407 +23,416 @@ const (
|
|||
CodeStructEnd CodeType = 11
|
||||
)
|
||||
|
||||
var opTypeStrings = [400]string{
|
||||
"End",
|
||||
"Interface",
|
||||
"Ptr",
|
||||
"SliceElem",
|
||||
"SliceEnd",
|
||||
"ArrayElem",
|
||||
"ArrayEnd",
|
||||
"MapKey",
|
||||
"MapValue",
|
||||
"MapEnd",
|
||||
"Recursive",
|
||||
"RecursivePtr",
|
||||
"RecursiveEnd",
|
||||
"InterfaceEnd",
|
||||
"Int",
|
||||
"Uint",
|
||||
"Float32",
|
||||
"Float64",
|
||||
"Bool",
|
||||
"String",
|
||||
"Bytes",
|
||||
"Number",
|
||||
"Array",
|
||||
"Map",
|
||||
"Slice",
|
||||
"Struct",
|
||||
"MarshalJSON",
|
||||
"MarshalText",
|
||||
"IntString",
|
||||
"UintString",
|
||||
"Float32String",
|
||||
"Float64String",
|
||||
"BoolString",
|
||||
"StringString",
|
||||
"NumberString",
|
||||
"IntPtr",
|
||||
"UintPtr",
|
||||
"Float32Ptr",
|
||||
"Float64Ptr",
|
||||
"BoolPtr",
|
||||
"StringPtr",
|
||||
"BytesPtr",
|
||||
"NumberPtr",
|
||||
"ArrayPtr",
|
||||
"MapPtr",
|
||||
"SlicePtr",
|
||||
"MarshalJSONPtr",
|
||||
"MarshalTextPtr",
|
||||
"InterfacePtr",
|
||||
"IntPtrString",
|
||||
"UintPtrString",
|
||||
"Float32PtrString",
|
||||
"Float64PtrString",
|
||||
"BoolPtrString",
|
||||
"StringPtrString",
|
||||
"NumberPtrString",
|
||||
"StructHeadInt",
|
||||
"StructHeadOmitEmptyInt",
|
||||
"StructPtrHeadInt",
|
||||
"StructPtrHeadOmitEmptyInt",
|
||||
"StructHeadUint",
|
||||
"StructHeadOmitEmptyUint",
|
||||
"StructPtrHeadUint",
|
||||
"StructPtrHeadOmitEmptyUint",
|
||||
"StructHeadFloat32",
|
||||
"StructHeadOmitEmptyFloat32",
|
||||
"StructPtrHeadFloat32",
|
||||
"StructPtrHeadOmitEmptyFloat32",
|
||||
"StructHeadFloat64",
|
||||
"StructHeadOmitEmptyFloat64",
|
||||
"StructPtrHeadFloat64",
|
||||
"StructPtrHeadOmitEmptyFloat64",
|
||||
"StructHeadBool",
|
||||
"StructHeadOmitEmptyBool",
|
||||
"StructPtrHeadBool",
|
||||
"StructPtrHeadOmitEmptyBool",
|
||||
"StructHeadString",
|
||||
"StructHeadOmitEmptyString",
|
||||
"StructPtrHeadString",
|
||||
"StructPtrHeadOmitEmptyString",
|
||||
"StructHeadBytes",
|
||||
"StructHeadOmitEmptyBytes",
|
||||
"StructPtrHeadBytes",
|
||||
"StructPtrHeadOmitEmptyBytes",
|
||||
"StructHeadNumber",
|
||||
"StructHeadOmitEmptyNumber",
|
||||
"StructPtrHeadNumber",
|
||||
"StructPtrHeadOmitEmptyNumber",
|
||||
"StructHeadArray",
|
||||
"StructHeadOmitEmptyArray",
|
||||
"StructPtrHeadArray",
|
||||
"StructPtrHeadOmitEmptyArray",
|
||||
"StructHeadMap",
|
||||
"StructHeadOmitEmptyMap",
|
||||
"StructPtrHeadMap",
|
||||
"StructPtrHeadOmitEmptyMap",
|
||||
"StructHeadSlice",
|
||||
"StructHeadOmitEmptySlice",
|
||||
"StructPtrHeadSlice",
|
||||
"StructPtrHeadOmitEmptySlice",
|
||||
"StructHeadStruct",
|
||||
"StructHeadOmitEmptyStruct",
|
||||
"StructPtrHeadStruct",
|
||||
"StructPtrHeadOmitEmptyStruct",
|
||||
"StructHeadMarshalJSON",
|
||||
"StructHeadOmitEmptyMarshalJSON",
|
||||
"StructPtrHeadMarshalJSON",
|
||||
"StructPtrHeadOmitEmptyMarshalJSON",
|
||||
"StructHeadMarshalText",
|
||||
"StructHeadOmitEmptyMarshalText",
|
||||
"StructPtrHeadMarshalText",
|
||||
"StructPtrHeadOmitEmptyMarshalText",
|
||||
"StructHeadIntString",
|
||||
"StructHeadOmitEmptyIntString",
|
||||
"StructPtrHeadIntString",
|
||||
"StructPtrHeadOmitEmptyIntString",
|
||||
"StructHeadUintString",
|
||||
"StructHeadOmitEmptyUintString",
|
||||
"StructPtrHeadUintString",
|
||||
"StructPtrHeadOmitEmptyUintString",
|
||||
"StructHeadFloat32String",
|
||||
"StructHeadOmitEmptyFloat32String",
|
||||
"StructPtrHeadFloat32String",
|
||||
"StructPtrHeadOmitEmptyFloat32String",
|
||||
"StructHeadFloat64String",
|
||||
"StructHeadOmitEmptyFloat64String",
|
||||
"StructPtrHeadFloat64String",
|
||||
"StructPtrHeadOmitEmptyFloat64String",
|
||||
"StructHeadBoolString",
|
||||
"StructHeadOmitEmptyBoolString",
|
||||
"StructPtrHeadBoolString",
|
||||
"StructPtrHeadOmitEmptyBoolString",
|
||||
"StructHeadStringString",
|
||||
"StructHeadOmitEmptyStringString",
|
||||
"StructPtrHeadStringString",
|
||||
"StructPtrHeadOmitEmptyStringString",
|
||||
"StructHeadNumberString",
|
||||
"StructHeadOmitEmptyNumberString",
|
||||
"StructPtrHeadNumberString",
|
||||
"StructPtrHeadOmitEmptyNumberString",
|
||||
"StructHeadIntPtr",
|
||||
"StructHeadOmitEmptyIntPtr",
|
||||
"StructPtrHeadIntPtr",
|
||||
"StructPtrHeadOmitEmptyIntPtr",
|
||||
"StructHeadUintPtr",
|
||||
"StructHeadOmitEmptyUintPtr",
|
||||
"StructPtrHeadUintPtr",
|
||||
"StructPtrHeadOmitEmptyUintPtr",
|
||||
"StructHeadFloat32Ptr",
|
||||
"StructHeadOmitEmptyFloat32Ptr",
|
||||
"StructPtrHeadFloat32Ptr",
|
||||
"StructPtrHeadOmitEmptyFloat32Ptr",
|
||||
"StructHeadFloat64Ptr",
|
||||
"StructHeadOmitEmptyFloat64Ptr",
|
||||
"StructPtrHeadFloat64Ptr",
|
||||
"StructPtrHeadOmitEmptyFloat64Ptr",
|
||||
"StructHeadBoolPtr",
|
||||
"StructHeadOmitEmptyBoolPtr",
|
||||
"StructPtrHeadBoolPtr",
|
||||
"StructPtrHeadOmitEmptyBoolPtr",
|
||||
"StructHeadStringPtr",
|
||||
"StructHeadOmitEmptyStringPtr",
|
||||
"StructPtrHeadStringPtr",
|
||||
"StructPtrHeadOmitEmptyStringPtr",
|
||||
"StructHeadBytesPtr",
|
||||
"StructHeadOmitEmptyBytesPtr",
|
||||
"StructPtrHeadBytesPtr",
|
||||
"StructPtrHeadOmitEmptyBytesPtr",
|
||||
"StructHeadNumberPtr",
|
||||
"StructHeadOmitEmptyNumberPtr",
|
||||
"StructPtrHeadNumberPtr",
|
||||
"StructPtrHeadOmitEmptyNumberPtr",
|
||||
"StructHeadArrayPtr",
|
||||
"StructHeadOmitEmptyArrayPtr",
|
||||
"StructPtrHeadArrayPtr",
|
||||
"StructPtrHeadOmitEmptyArrayPtr",
|
||||
"StructHeadMapPtr",
|
||||
"StructHeadOmitEmptyMapPtr",
|
||||
"StructPtrHeadMapPtr",
|
||||
"StructPtrHeadOmitEmptyMapPtr",
|
||||
"StructHeadSlicePtr",
|
||||
"StructHeadOmitEmptySlicePtr",
|
||||
"StructPtrHeadSlicePtr",
|
||||
"StructPtrHeadOmitEmptySlicePtr",
|
||||
"StructHeadMarshalJSONPtr",
|
||||
"StructHeadOmitEmptyMarshalJSONPtr",
|
||||
"StructPtrHeadMarshalJSONPtr",
|
||||
"StructPtrHeadOmitEmptyMarshalJSONPtr",
|
||||
"StructHeadMarshalTextPtr",
|
||||
"StructHeadOmitEmptyMarshalTextPtr",
|
||||
"StructPtrHeadMarshalTextPtr",
|
||||
"StructPtrHeadOmitEmptyMarshalTextPtr",
|
||||
"StructHeadInterfacePtr",
|
||||
"StructHeadOmitEmptyInterfacePtr",
|
||||
"StructPtrHeadInterfacePtr",
|
||||
"StructPtrHeadOmitEmptyInterfacePtr",
|
||||
"StructHeadIntPtrString",
|
||||
"StructHeadOmitEmptyIntPtrString",
|
||||
"StructPtrHeadIntPtrString",
|
||||
"StructPtrHeadOmitEmptyIntPtrString",
|
||||
"StructHeadUintPtrString",
|
||||
"StructHeadOmitEmptyUintPtrString",
|
||||
"StructPtrHeadUintPtrString",
|
||||
"StructPtrHeadOmitEmptyUintPtrString",
|
||||
"StructHeadFloat32PtrString",
|
||||
"StructHeadOmitEmptyFloat32PtrString",
|
||||
"StructPtrHeadFloat32PtrString",
|
||||
"StructPtrHeadOmitEmptyFloat32PtrString",
|
||||
"StructHeadFloat64PtrString",
|
||||
"StructHeadOmitEmptyFloat64PtrString",
|
||||
"StructPtrHeadFloat64PtrString",
|
||||
"StructPtrHeadOmitEmptyFloat64PtrString",
|
||||
"StructHeadBoolPtrString",
|
||||
"StructHeadOmitEmptyBoolPtrString",
|
||||
"StructPtrHeadBoolPtrString",
|
||||
"StructPtrHeadOmitEmptyBoolPtrString",
|
||||
"StructHeadStringPtrString",
|
||||
"StructHeadOmitEmptyStringPtrString",
|
||||
"StructPtrHeadStringPtrString",
|
||||
"StructPtrHeadOmitEmptyStringPtrString",
|
||||
"StructHeadNumberPtrString",
|
||||
"StructHeadOmitEmptyNumberPtrString",
|
||||
"StructPtrHeadNumberPtrString",
|
||||
"StructPtrHeadOmitEmptyNumberPtrString",
|
||||
"StructHead",
|
||||
"StructHeadOmitEmpty",
|
||||
"StructPtrHead",
|
||||
"StructPtrHeadOmitEmpty",
|
||||
"StructFieldInt",
|
||||
"StructFieldOmitEmptyInt",
|
||||
"StructEndInt",
|
||||
"StructEndOmitEmptyInt",
|
||||
"StructFieldUint",
|
||||
"StructFieldOmitEmptyUint",
|
||||
"StructEndUint",
|
||||
"StructEndOmitEmptyUint",
|
||||
"StructFieldFloat32",
|
||||
"StructFieldOmitEmptyFloat32",
|
||||
"StructEndFloat32",
|
||||
"StructEndOmitEmptyFloat32",
|
||||
"StructFieldFloat64",
|
||||
"StructFieldOmitEmptyFloat64",
|
||||
"StructEndFloat64",
|
||||
"StructEndOmitEmptyFloat64",
|
||||
"StructFieldBool",
|
||||
"StructFieldOmitEmptyBool",
|
||||
"StructEndBool",
|
||||
"StructEndOmitEmptyBool",
|
||||
"StructFieldString",
|
||||
"StructFieldOmitEmptyString",
|
||||
"StructEndString",
|
||||
"StructEndOmitEmptyString",
|
||||
"StructFieldBytes",
|
||||
"StructFieldOmitEmptyBytes",
|
||||
"StructEndBytes",
|
||||
"StructEndOmitEmptyBytes",
|
||||
"StructFieldNumber",
|
||||
"StructFieldOmitEmptyNumber",
|
||||
"StructEndNumber",
|
||||
"StructEndOmitEmptyNumber",
|
||||
"StructFieldArray",
|
||||
"StructFieldOmitEmptyArray",
|
||||
"StructEndArray",
|
||||
"StructEndOmitEmptyArray",
|
||||
"StructFieldMap",
|
||||
"StructFieldOmitEmptyMap",
|
||||
"StructEndMap",
|
||||
"StructEndOmitEmptyMap",
|
||||
"StructFieldSlice",
|
||||
"StructFieldOmitEmptySlice",
|
||||
"StructEndSlice",
|
||||
"StructEndOmitEmptySlice",
|
||||
"StructFieldStruct",
|
||||
"StructFieldOmitEmptyStruct",
|
||||
"StructEndStruct",
|
||||
"StructEndOmitEmptyStruct",
|
||||
"StructFieldMarshalJSON",
|
||||
"StructFieldOmitEmptyMarshalJSON",
|
||||
"StructEndMarshalJSON",
|
||||
"StructEndOmitEmptyMarshalJSON",
|
||||
"StructFieldMarshalText",
|
||||
"StructFieldOmitEmptyMarshalText",
|
||||
"StructEndMarshalText",
|
||||
"StructEndOmitEmptyMarshalText",
|
||||
"StructFieldIntString",
|
||||
"StructFieldOmitEmptyIntString",
|
||||
"StructEndIntString",
|
||||
"StructEndOmitEmptyIntString",
|
||||
"StructFieldUintString",
|
||||
"StructFieldOmitEmptyUintString",
|
||||
"StructEndUintString",
|
||||
"StructEndOmitEmptyUintString",
|
||||
"StructFieldFloat32String",
|
||||
"StructFieldOmitEmptyFloat32String",
|
||||
"StructEndFloat32String",
|
||||
"StructEndOmitEmptyFloat32String",
|
||||
"StructFieldFloat64String",
|
||||
"StructFieldOmitEmptyFloat64String",
|
||||
"StructEndFloat64String",
|
||||
"StructEndOmitEmptyFloat64String",
|
||||
"StructFieldBoolString",
|
||||
"StructFieldOmitEmptyBoolString",
|
||||
"StructEndBoolString",
|
||||
"StructEndOmitEmptyBoolString",
|
||||
"StructFieldStringString",
|
||||
"StructFieldOmitEmptyStringString",
|
||||
"StructEndStringString",
|
||||
"StructEndOmitEmptyStringString",
|
||||
"StructFieldNumberString",
|
||||
"StructFieldOmitEmptyNumberString",
|
||||
"StructEndNumberString",
|
||||
"StructEndOmitEmptyNumberString",
|
||||
"StructFieldIntPtr",
|
||||
"StructFieldOmitEmptyIntPtr",
|
||||
"StructEndIntPtr",
|
||||
"StructEndOmitEmptyIntPtr",
|
||||
"StructFieldUintPtr",
|
||||
"StructFieldOmitEmptyUintPtr",
|
||||
"StructEndUintPtr",
|
||||
"StructEndOmitEmptyUintPtr",
|
||||
"StructFieldFloat32Ptr",
|
||||
"StructFieldOmitEmptyFloat32Ptr",
|
||||
"StructEndFloat32Ptr",
|
||||
"StructEndOmitEmptyFloat32Ptr",
|
||||
"StructFieldFloat64Ptr",
|
||||
"StructFieldOmitEmptyFloat64Ptr",
|
||||
"StructEndFloat64Ptr",
|
||||
"StructEndOmitEmptyFloat64Ptr",
|
||||
"StructFieldBoolPtr",
|
||||
"StructFieldOmitEmptyBoolPtr",
|
||||
"StructEndBoolPtr",
|
||||
"StructEndOmitEmptyBoolPtr",
|
||||
"StructFieldStringPtr",
|
||||
"StructFieldOmitEmptyStringPtr",
|
||||
"StructEndStringPtr",
|
||||
"StructEndOmitEmptyStringPtr",
|
||||
"StructFieldBytesPtr",
|
||||
"StructFieldOmitEmptyBytesPtr",
|
||||
"StructEndBytesPtr",
|
||||
"StructEndOmitEmptyBytesPtr",
|
||||
"StructFieldNumberPtr",
|
||||
"StructFieldOmitEmptyNumberPtr",
|
||||
"StructEndNumberPtr",
|
||||
"StructEndOmitEmptyNumberPtr",
|
||||
"StructFieldArrayPtr",
|
||||
"StructFieldOmitEmptyArrayPtr",
|
||||
"StructEndArrayPtr",
|
||||
"StructEndOmitEmptyArrayPtr",
|
||||
"StructFieldMapPtr",
|
||||
"StructFieldOmitEmptyMapPtr",
|
||||
"StructEndMapPtr",
|
||||
"StructEndOmitEmptyMapPtr",
|
||||
"StructFieldSlicePtr",
|
||||
"StructFieldOmitEmptySlicePtr",
|
||||
"StructEndSlicePtr",
|
||||
"StructEndOmitEmptySlicePtr",
|
||||
"StructFieldMarshalJSONPtr",
|
||||
"StructFieldOmitEmptyMarshalJSONPtr",
|
||||
"StructEndMarshalJSONPtr",
|
||||
"StructEndOmitEmptyMarshalJSONPtr",
|
||||
"StructFieldMarshalTextPtr",
|
||||
"StructFieldOmitEmptyMarshalTextPtr",
|
||||
"StructEndMarshalTextPtr",
|
||||
"StructEndOmitEmptyMarshalTextPtr",
|
||||
"StructFieldInterfacePtr",
|
||||
"StructFieldOmitEmptyInterfacePtr",
|
||||
"StructEndInterfacePtr",
|
||||
"StructEndOmitEmptyInterfacePtr",
|
||||
"StructFieldIntPtrString",
|
||||
"StructFieldOmitEmptyIntPtrString",
|
||||
"StructEndIntPtrString",
|
||||
"StructEndOmitEmptyIntPtrString",
|
||||
"StructFieldUintPtrString",
|
||||
"StructFieldOmitEmptyUintPtrString",
|
||||
"StructEndUintPtrString",
|
||||
"StructEndOmitEmptyUintPtrString",
|
||||
"StructFieldFloat32PtrString",
|
||||
"StructFieldOmitEmptyFloat32PtrString",
|
||||
"StructEndFloat32PtrString",
|
||||
"StructEndOmitEmptyFloat32PtrString",
|
||||
"StructFieldFloat64PtrString",
|
||||
"StructFieldOmitEmptyFloat64PtrString",
|
||||
"StructEndFloat64PtrString",
|
||||
"StructEndOmitEmptyFloat64PtrString",
|
||||
"StructFieldBoolPtrString",
|
||||
"StructFieldOmitEmptyBoolPtrString",
|
||||
"StructEndBoolPtrString",
|
||||
"StructEndOmitEmptyBoolPtrString",
|
||||
"StructFieldStringPtrString",
|
||||
"StructFieldOmitEmptyStringPtrString",
|
||||
"StructEndStringPtrString",
|
||||
"StructEndOmitEmptyStringPtrString",
|
||||
"StructFieldNumberPtrString",
|
||||
"StructFieldOmitEmptyNumberPtrString",
|
||||
"StructEndNumberPtrString",
|
||||
"StructEndOmitEmptyNumberPtrString",
|
||||
"StructField",
|
||||
"StructFieldOmitEmpty",
|
||||
"StructEnd",
|
||||
"StructEndOmitEmpty",
|
||||
var (
|
||||
opTypeStrings *[400]string
|
||||
initOpTypeOnce sync.Once
|
||||
)
|
||||
|
||||
func initOpType() {
|
||||
initOpTypeOnce.Do(func() {
|
||||
opTypeStrings = &[400]string{
|
||||
"End",
|
||||
"Interface",
|
||||
"Ptr",
|
||||
"SliceElem",
|
||||
"SliceEnd",
|
||||
"ArrayElem",
|
||||
"ArrayEnd",
|
||||
"MapKey",
|
||||
"MapValue",
|
||||
"MapEnd",
|
||||
"Recursive",
|
||||
"RecursivePtr",
|
||||
"RecursiveEnd",
|
||||
"InterfaceEnd",
|
||||
"Int",
|
||||
"Uint",
|
||||
"Float32",
|
||||
"Float64",
|
||||
"Bool",
|
||||
"String",
|
||||
"Bytes",
|
||||
"Number",
|
||||
"Array",
|
||||
"Map",
|
||||
"Slice",
|
||||
"Struct",
|
||||
"MarshalJSON",
|
||||
"MarshalText",
|
||||
"IntString",
|
||||
"UintString",
|
||||
"Float32String",
|
||||
"Float64String",
|
||||
"BoolString",
|
||||
"StringString",
|
||||
"NumberString",
|
||||
"IntPtr",
|
||||
"UintPtr",
|
||||
"Float32Ptr",
|
||||
"Float64Ptr",
|
||||
"BoolPtr",
|
||||
"StringPtr",
|
||||
"BytesPtr",
|
||||
"NumberPtr",
|
||||
"ArrayPtr",
|
||||
"MapPtr",
|
||||
"SlicePtr",
|
||||
"MarshalJSONPtr",
|
||||
"MarshalTextPtr",
|
||||
"InterfacePtr",
|
||||
"IntPtrString",
|
||||
"UintPtrString",
|
||||
"Float32PtrString",
|
||||
"Float64PtrString",
|
||||
"BoolPtrString",
|
||||
"StringPtrString",
|
||||
"NumberPtrString",
|
||||
"StructHeadInt",
|
||||
"StructHeadOmitEmptyInt",
|
||||
"StructPtrHeadInt",
|
||||
"StructPtrHeadOmitEmptyInt",
|
||||
"StructHeadUint",
|
||||
"StructHeadOmitEmptyUint",
|
||||
"StructPtrHeadUint",
|
||||
"StructPtrHeadOmitEmptyUint",
|
||||
"StructHeadFloat32",
|
||||
"StructHeadOmitEmptyFloat32",
|
||||
"StructPtrHeadFloat32",
|
||||
"StructPtrHeadOmitEmptyFloat32",
|
||||
"StructHeadFloat64",
|
||||
"StructHeadOmitEmptyFloat64",
|
||||
"StructPtrHeadFloat64",
|
||||
"StructPtrHeadOmitEmptyFloat64",
|
||||
"StructHeadBool",
|
||||
"StructHeadOmitEmptyBool",
|
||||
"StructPtrHeadBool",
|
||||
"StructPtrHeadOmitEmptyBool",
|
||||
"StructHeadString",
|
||||
"StructHeadOmitEmptyString",
|
||||
"StructPtrHeadString",
|
||||
"StructPtrHeadOmitEmptyString",
|
||||
"StructHeadBytes",
|
||||
"StructHeadOmitEmptyBytes",
|
||||
"StructPtrHeadBytes",
|
||||
"StructPtrHeadOmitEmptyBytes",
|
||||
"StructHeadNumber",
|
||||
"StructHeadOmitEmptyNumber",
|
||||
"StructPtrHeadNumber",
|
||||
"StructPtrHeadOmitEmptyNumber",
|
||||
"StructHeadArray",
|
||||
"StructHeadOmitEmptyArray",
|
||||
"StructPtrHeadArray",
|
||||
"StructPtrHeadOmitEmptyArray",
|
||||
"StructHeadMap",
|
||||
"StructHeadOmitEmptyMap",
|
||||
"StructPtrHeadMap",
|
||||
"StructPtrHeadOmitEmptyMap",
|
||||
"StructHeadSlice",
|
||||
"StructHeadOmitEmptySlice",
|
||||
"StructPtrHeadSlice",
|
||||
"StructPtrHeadOmitEmptySlice",
|
||||
"StructHeadStruct",
|
||||
"StructHeadOmitEmptyStruct",
|
||||
"StructPtrHeadStruct",
|
||||
"StructPtrHeadOmitEmptyStruct",
|
||||
"StructHeadMarshalJSON",
|
||||
"StructHeadOmitEmptyMarshalJSON",
|
||||
"StructPtrHeadMarshalJSON",
|
||||
"StructPtrHeadOmitEmptyMarshalJSON",
|
||||
"StructHeadMarshalText",
|
||||
"StructHeadOmitEmptyMarshalText",
|
||||
"StructPtrHeadMarshalText",
|
||||
"StructPtrHeadOmitEmptyMarshalText",
|
||||
"StructHeadIntString",
|
||||
"StructHeadOmitEmptyIntString",
|
||||
"StructPtrHeadIntString",
|
||||
"StructPtrHeadOmitEmptyIntString",
|
||||
"StructHeadUintString",
|
||||
"StructHeadOmitEmptyUintString",
|
||||
"StructPtrHeadUintString",
|
||||
"StructPtrHeadOmitEmptyUintString",
|
||||
"StructHeadFloat32String",
|
||||
"StructHeadOmitEmptyFloat32String",
|
||||
"StructPtrHeadFloat32String",
|
||||
"StructPtrHeadOmitEmptyFloat32String",
|
||||
"StructHeadFloat64String",
|
||||
"StructHeadOmitEmptyFloat64String",
|
||||
"StructPtrHeadFloat64String",
|
||||
"StructPtrHeadOmitEmptyFloat64String",
|
||||
"StructHeadBoolString",
|
||||
"StructHeadOmitEmptyBoolString",
|
||||
"StructPtrHeadBoolString",
|
||||
"StructPtrHeadOmitEmptyBoolString",
|
||||
"StructHeadStringString",
|
||||
"StructHeadOmitEmptyStringString",
|
||||
"StructPtrHeadStringString",
|
||||
"StructPtrHeadOmitEmptyStringString",
|
||||
"StructHeadNumberString",
|
||||
"StructHeadOmitEmptyNumberString",
|
||||
"StructPtrHeadNumberString",
|
||||
"StructPtrHeadOmitEmptyNumberString",
|
||||
"StructHeadIntPtr",
|
||||
"StructHeadOmitEmptyIntPtr",
|
||||
"StructPtrHeadIntPtr",
|
||||
"StructPtrHeadOmitEmptyIntPtr",
|
||||
"StructHeadUintPtr",
|
||||
"StructHeadOmitEmptyUintPtr",
|
||||
"StructPtrHeadUintPtr",
|
||||
"StructPtrHeadOmitEmptyUintPtr",
|
||||
"StructHeadFloat32Ptr",
|
||||
"StructHeadOmitEmptyFloat32Ptr",
|
||||
"StructPtrHeadFloat32Ptr",
|
||||
"StructPtrHeadOmitEmptyFloat32Ptr",
|
||||
"StructHeadFloat64Ptr",
|
||||
"StructHeadOmitEmptyFloat64Ptr",
|
||||
"StructPtrHeadFloat64Ptr",
|
||||
"StructPtrHeadOmitEmptyFloat64Ptr",
|
||||
"StructHeadBoolPtr",
|
||||
"StructHeadOmitEmptyBoolPtr",
|
||||
"StructPtrHeadBoolPtr",
|
||||
"StructPtrHeadOmitEmptyBoolPtr",
|
||||
"StructHeadStringPtr",
|
||||
"StructHeadOmitEmptyStringPtr",
|
||||
"StructPtrHeadStringPtr",
|
||||
"StructPtrHeadOmitEmptyStringPtr",
|
||||
"StructHeadBytesPtr",
|
||||
"StructHeadOmitEmptyBytesPtr",
|
||||
"StructPtrHeadBytesPtr",
|
||||
"StructPtrHeadOmitEmptyBytesPtr",
|
||||
"StructHeadNumberPtr",
|
||||
"StructHeadOmitEmptyNumberPtr",
|
||||
"StructPtrHeadNumberPtr",
|
||||
"StructPtrHeadOmitEmptyNumberPtr",
|
||||
"StructHeadArrayPtr",
|
||||
"StructHeadOmitEmptyArrayPtr",
|
||||
"StructPtrHeadArrayPtr",
|
||||
"StructPtrHeadOmitEmptyArrayPtr",
|
||||
"StructHeadMapPtr",
|
||||
"StructHeadOmitEmptyMapPtr",
|
||||
"StructPtrHeadMapPtr",
|
||||
"StructPtrHeadOmitEmptyMapPtr",
|
||||
"StructHeadSlicePtr",
|
||||
"StructHeadOmitEmptySlicePtr",
|
||||
"StructPtrHeadSlicePtr",
|
||||
"StructPtrHeadOmitEmptySlicePtr",
|
||||
"StructHeadMarshalJSONPtr",
|
||||
"StructHeadOmitEmptyMarshalJSONPtr",
|
||||
"StructPtrHeadMarshalJSONPtr",
|
||||
"StructPtrHeadOmitEmptyMarshalJSONPtr",
|
||||
"StructHeadMarshalTextPtr",
|
||||
"StructHeadOmitEmptyMarshalTextPtr",
|
||||
"StructPtrHeadMarshalTextPtr",
|
||||
"StructPtrHeadOmitEmptyMarshalTextPtr",
|
||||
"StructHeadInterfacePtr",
|
||||
"StructHeadOmitEmptyInterfacePtr",
|
||||
"StructPtrHeadInterfacePtr",
|
||||
"StructPtrHeadOmitEmptyInterfacePtr",
|
||||
"StructHeadIntPtrString",
|
||||
"StructHeadOmitEmptyIntPtrString",
|
||||
"StructPtrHeadIntPtrString",
|
||||
"StructPtrHeadOmitEmptyIntPtrString",
|
||||
"StructHeadUintPtrString",
|
||||
"StructHeadOmitEmptyUintPtrString",
|
||||
"StructPtrHeadUintPtrString",
|
||||
"StructPtrHeadOmitEmptyUintPtrString",
|
||||
"StructHeadFloat32PtrString",
|
||||
"StructHeadOmitEmptyFloat32PtrString",
|
||||
"StructPtrHeadFloat32PtrString",
|
||||
"StructPtrHeadOmitEmptyFloat32PtrString",
|
||||
"StructHeadFloat64PtrString",
|
||||
"StructHeadOmitEmptyFloat64PtrString",
|
||||
"StructPtrHeadFloat64PtrString",
|
||||
"StructPtrHeadOmitEmptyFloat64PtrString",
|
||||
"StructHeadBoolPtrString",
|
||||
"StructHeadOmitEmptyBoolPtrString",
|
||||
"StructPtrHeadBoolPtrString",
|
||||
"StructPtrHeadOmitEmptyBoolPtrString",
|
||||
"StructHeadStringPtrString",
|
||||
"StructHeadOmitEmptyStringPtrString",
|
||||
"StructPtrHeadStringPtrString",
|
||||
"StructPtrHeadOmitEmptyStringPtrString",
|
||||
"StructHeadNumberPtrString",
|
||||
"StructHeadOmitEmptyNumberPtrString",
|
||||
"StructPtrHeadNumberPtrString",
|
||||
"StructPtrHeadOmitEmptyNumberPtrString",
|
||||
"StructHead",
|
||||
"StructHeadOmitEmpty",
|
||||
"StructPtrHead",
|
||||
"StructPtrHeadOmitEmpty",
|
||||
"StructFieldInt",
|
||||
"StructFieldOmitEmptyInt",
|
||||
"StructEndInt",
|
||||
"StructEndOmitEmptyInt",
|
||||
"StructFieldUint",
|
||||
"StructFieldOmitEmptyUint",
|
||||
"StructEndUint",
|
||||
"StructEndOmitEmptyUint",
|
||||
"StructFieldFloat32",
|
||||
"StructFieldOmitEmptyFloat32",
|
||||
"StructEndFloat32",
|
||||
"StructEndOmitEmptyFloat32",
|
||||
"StructFieldFloat64",
|
||||
"StructFieldOmitEmptyFloat64",
|
||||
"StructEndFloat64",
|
||||
"StructEndOmitEmptyFloat64",
|
||||
"StructFieldBool",
|
||||
"StructFieldOmitEmptyBool",
|
||||
"StructEndBool",
|
||||
"StructEndOmitEmptyBool",
|
||||
"StructFieldString",
|
||||
"StructFieldOmitEmptyString",
|
||||
"StructEndString",
|
||||
"StructEndOmitEmptyString",
|
||||
"StructFieldBytes",
|
||||
"StructFieldOmitEmptyBytes",
|
||||
"StructEndBytes",
|
||||
"StructEndOmitEmptyBytes",
|
||||
"StructFieldNumber",
|
||||
"StructFieldOmitEmptyNumber",
|
||||
"StructEndNumber",
|
||||
"StructEndOmitEmptyNumber",
|
||||
"StructFieldArray",
|
||||
"StructFieldOmitEmptyArray",
|
||||
"StructEndArray",
|
||||
"StructEndOmitEmptyArray",
|
||||
"StructFieldMap",
|
||||
"StructFieldOmitEmptyMap",
|
||||
"StructEndMap",
|
||||
"StructEndOmitEmptyMap",
|
||||
"StructFieldSlice",
|
||||
"StructFieldOmitEmptySlice",
|
||||
"StructEndSlice",
|
||||
"StructEndOmitEmptySlice",
|
||||
"StructFieldStruct",
|
||||
"StructFieldOmitEmptyStruct",
|
||||
"StructEndStruct",
|
||||
"StructEndOmitEmptyStruct",
|
||||
"StructFieldMarshalJSON",
|
||||
"StructFieldOmitEmptyMarshalJSON",
|
||||
"StructEndMarshalJSON",
|
||||
"StructEndOmitEmptyMarshalJSON",
|
||||
"StructFieldMarshalText",
|
||||
"StructFieldOmitEmptyMarshalText",
|
||||
"StructEndMarshalText",
|
||||
"StructEndOmitEmptyMarshalText",
|
||||
"StructFieldIntString",
|
||||
"StructFieldOmitEmptyIntString",
|
||||
"StructEndIntString",
|
||||
"StructEndOmitEmptyIntString",
|
||||
"StructFieldUintString",
|
||||
"StructFieldOmitEmptyUintString",
|
||||
"StructEndUintString",
|
||||
"StructEndOmitEmptyUintString",
|
||||
"StructFieldFloat32String",
|
||||
"StructFieldOmitEmptyFloat32String",
|
||||
"StructEndFloat32String",
|
||||
"StructEndOmitEmptyFloat32String",
|
||||
"StructFieldFloat64String",
|
||||
"StructFieldOmitEmptyFloat64String",
|
||||
"StructEndFloat64String",
|
||||
"StructEndOmitEmptyFloat64String",
|
||||
"StructFieldBoolString",
|
||||
"StructFieldOmitEmptyBoolString",
|
||||
"StructEndBoolString",
|
||||
"StructEndOmitEmptyBoolString",
|
||||
"StructFieldStringString",
|
||||
"StructFieldOmitEmptyStringString",
|
||||
"StructEndStringString",
|
||||
"StructEndOmitEmptyStringString",
|
||||
"StructFieldNumberString",
|
||||
"StructFieldOmitEmptyNumberString",
|
||||
"StructEndNumberString",
|
||||
"StructEndOmitEmptyNumberString",
|
||||
"StructFieldIntPtr",
|
||||
"StructFieldOmitEmptyIntPtr",
|
||||
"StructEndIntPtr",
|
||||
"StructEndOmitEmptyIntPtr",
|
||||
"StructFieldUintPtr",
|
||||
"StructFieldOmitEmptyUintPtr",
|
||||
"StructEndUintPtr",
|
||||
"StructEndOmitEmptyUintPtr",
|
||||
"StructFieldFloat32Ptr",
|
||||
"StructFieldOmitEmptyFloat32Ptr",
|
||||
"StructEndFloat32Ptr",
|
||||
"StructEndOmitEmptyFloat32Ptr",
|
||||
"StructFieldFloat64Ptr",
|
||||
"StructFieldOmitEmptyFloat64Ptr",
|
||||
"StructEndFloat64Ptr",
|
||||
"StructEndOmitEmptyFloat64Ptr",
|
||||
"StructFieldBoolPtr",
|
||||
"StructFieldOmitEmptyBoolPtr",
|
||||
"StructEndBoolPtr",
|
||||
"StructEndOmitEmptyBoolPtr",
|
||||
"StructFieldStringPtr",
|
||||
"StructFieldOmitEmptyStringPtr",
|
||||
"StructEndStringPtr",
|
||||
"StructEndOmitEmptyStringPtr",
|
||||
"StructFieldBytesPtr",
|
||||
"StructFieldOmitEmptyBytesPtr",
|
||||
"StructEndBytesPtr",
|
||||
"StructEndOmitEmptyBytesPtr",
|
||||
"StructFieldNumberPtr",
|
||||
"StructFieldOmitEmptyNumberPtr",
|
||||
"StructEndNumberPtr",
|
||||
"StructEndOmitEmptyNumberPtr",
|
||||
"StructFieldArrayPtr",
|
||||
"StructFieldOmitEmptyArrayPtr",
|
||||
"StructEndArrayPtr",
|
||||
"StructEndOmitEmptyArrayPtr",
|
||||
"StructFieldMapPtr",
|
||||
"StructFieldOmitEmptyMapPtr",
|
||||
"StructEndMapPtr",
|
||||
"StructEndOmitEmptyMapPtr",
|
||||
"StructFieldSlicePtr",
|
||||
"StructFieldOmitEmptySlicePtr",
|
||||
"StructEndSlicePtr",
|
||||
"StructEndOmitEmptySlicePtr",
|
||||
"StructFieldMarshalJSONPtr",
|
||||
"StructFieldOmitEmptyMarshalJSONPtr",
|
||||
"StructEndMarshalJSONPtr",
|
||||
"StructEndOmitEmptyMarshalJSONPtr",
|
||||
"StructFieldMarshalTextPtr",
|
||||
"StructFieldOmitEmptyMarshalTextPtr",
|
||||
"StructEndMarshalTextPtr",
|
||||
"StructEndOmitEmptyMarshalTextPtr",
|
||||
"StructFieldInterfacePtr",
|
||||
"StructFieldOmitEmptyInterfacePtr",
|
||||
"StructEndInterfacePtr",
|
||||
"StructEndOmitEmptyInterfacePtr",
|
||||
"StructFieldIntPtrString",
|
||||
"StructFieldOmitEmptyIntPtrString",
|
||||
"StructEndIntPtrString",
|
||||
"StructEndOmitEmptyIntPtrString",
|
||||
"StructFieldUintPtrString",
|
||||
"StructFieldOmitEmptyUintPtrString",
|
||||
"StructEndUintPtrString",
|
||||
"StructEndOmitEmptyUintPtrString",
|
||||
"StructFieldFloat32PtrString",
|
||||
"StructFieldOmitEmptyFloat32PtrString",
|
||||
"StructEndFloat32PtrString",
|
||||
"StructEndOmitEmptyFloat32PtrString",
|
||||
"StructFieldFloat64PtrString",
|
||||
"StructFieldOmitEmptyFloat64PtrString",
|
||||
"StructEndFloat64PtrString",
|
||||
"StructEndOmitEmptyFloat64PtrString",
|
||||
"StructFieldBoolPtrString",
|
||||
"StructFieldOmitEmptyBoolPtrString",
|
||||
"StructEndBoolPtrString",
|
||||
"StructEndOmitEmptyBoolPtrString",
|
||||
"StructFieldStringPtrString",
|
||||
"StructFieldOmitEmptyStringPtrString",
|
||||
"StructEndStringPtrString",
|
||||
"StructEndOmitEmptyStringPtrString",
|
||||
"StructFieldNumberPtrString",
|
||||
"StructFieldOmitEmptyNumberPtrString",
|
||||
"StructEndNumberPtrString",
|
||||
"StructEndOmitEmptyNumberPtrString",
|
||||
"StructField",
|
||||
"StructFieldOmitEmpty",
|
||||
"StructEnd",
|
||||
"StructEndOmitEmpty",
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type OpType uint16
|
||||
|
@ -831,6 +841,8 @@ const (
|
|||
)
|
||||
|
||||
func (t OpType) String() string {
|
||||
initOpType() // lazy initialization
|
||||
|
||||
if int(t) >= 400 {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ func stringToUint64Slice(s string) []uint64 {
|
|||
}
|
||||
|
||||
func AppendString(ctx *RuntimeContext, buf []byte, s string) []byte {
|
||||
initStringTable() // lazy initialization
|
||||
|
||||
if ctx.Option.Flag&HTMLEscapeOption != 0 {
|
||||
if ctx.Option.Flag&NormalizeUTF8Option != 0 {
|
||||
return appendNormalizedHTMLString(buf, s)
|
||||
|
|
|
@ -1,415 +1,429 @@
|
|||
package encoder
|
||||
|
||||
var needEscapeHTMLNormalizeUTF8 = [256]bool{
|
||||
'"': true,
|
||||
'&': true,
|
||||
'<': true,
|
||||
'>': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0x7f */
|
||||
0x80: true,
|
||||
0x81: true,
|
||||
0x82: true,
|
||||
0x83: true,
|
||||
0x84: true,
|
||||
0x85: true,
|
||||
0x86: true,
|
||||
0x87: true,
|
||||
0x88: true,
|
||||
0x89: true,
|
||||
0x8a: true,
|
||||
0x8b: true,
|
||||
0x8c: true,
|
||||
0x8d: true,
|
||||
0x8e: true,
|
||||
0x8f: true,
|
||||
0x90: true,
|
||||
0x91: true,
|
||||
0x92: true,
|
||||
0x93: true,
|
||||
0x94: true,
|
||||
0x95: true,
|
||||
0x96: true,
|
||||
0x97: true,
|
||||
0x98: true,
|
||||
0x99: true,
|
||||
0x9a: true,
|
||||
0x9b: true,
|
||||
0x9c: true,
|
||||
0x9d: true,
|
||||
0x9e: true,
|
||||
0x9f: true,
|
||||
0xa0: true,
|
||||
0xa1: true,
|
||||
0xa2: true,
|
||||
0xa3: true,
|
||||
0xa4: true,
|
||||
0xa5: true,
|
||||
0xa6: true,
|
||||
0xa7: true,
|
||||
0xa8: true,
|
||||
0xa9: true,
|
||||
0xaa: true,
|
||||
0xab: true,
|
||||
0xac: true,
|
||||
0xad: true,
|
||||
0xae: true,
|
||||
0xaf: true,
|
||||
0xb0: true,
|
||||
0xb1: true,
|
||||
0xb2: true,
|
||||
0xb3: true,
|
||||
0xb4: true,
|
||||
0xb5: true,
|
||||
0xb6: true,
|
||||
0xb7: true,
|
||||
0xb8: true,
|
||||
0xb9: true,
|
||||
0xba: true,
|
||||
0xbb: true,
|
||||
0xbc: true,
|
||||
0xbd: true,
|
||||
0xbe: true,
|
||||
0xbf: true,
|
||||
0xc0: true,
|
||||
0xc1: true,
|
||||
0xc2: true,
|
||||
0xc3: true,
|
||||
0xc4: true,
|
||||
0xc5: true,
|
||||
0xc6: true,
|
||||
0xc7: true,
|
||||
0xc8: true,
|
||||
0xc9: true,
|
||||
0xca: true,
|
||||
0xcb: true,
|
||||
0xcc: true,
|
||||
0xcd: true,
|
||||
0xce: true,
|
||||
0xcf: true,
|
||||
0xd0: true,
|
||||
0xd1: true,
|
||||
0xd2: true,
|
||||
0xd3: true,
|
||||
0xd4: true,
|
||||
0xd5: true,
|
||||
0xd6: true,
|
||||
0xd7: true,
|
||||
0xd8: true,
|
||||
0xd9: true,
|
||||
0xda: true,
|
||||
0xdb: true,
|
||||
0xdc: true,
|
||||
0xdd: true,
|
||||
0xde: true,
|
||||
0xdf: true,
|
||||
0xe0: true,
|
||||
0xe1: true,
|
||||
0xe2: true,
|
||||
0xe3: true,
|
||||
0xe4: true,
|
||||
0xe5: true,
|
||||
0xe6: true,
|
||||
0xe7: true,
|
||||
0xe8: true,
|
||||
0xe9: true,
|
||||
0xea: true,
|
||||
0xeb: true,
|
||||
0xec: true,
|
||||
0xed: true,
|
||||
0xee: true,
|
||||
0xef: true,
|
||||
0xf0: true,
|
||||
0xf1: true,
|
||||
0xf2: true,
|
||||
0xf3: true,
|
||||
0xf4: true,
|
||||
0xf5: true,
|
||||
0xf6: true,
|
||||
0xf7: true,
|
||||
0xf8: true,
|
||||
0xf9: true,
|
||||
0xfa: true,
|
||||
0xfb: true,
|
||||
0xfc: true,
|
||||
0xfd: true,
|
||||
0xfe: true,
|
||||
0xff: true,
|
||||
}
|
||||
import "sync"
|
||||
|
||||
var needEscapeNormalizeUTF8 = [256]bool{
|
||||
'"': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0x7f */
|
||||
0x80: true,
|
||||
0x81: true,
|
||||
0x82: true,
|
||||
0x83: true,
|
||||
0x84: true,
|
||||
0x85: true,
|
||||
0x86: true,
|
||||
0x87: true,
|
||||
0x88: true,
|
||||
0x89: true,
|
||||
0x8a: true,
|
||||
0x8b: true,
|
||||
0x8c: true,
|
||||
0x8d: true,
|
||||
0x8e: true,
|
||||
0x8f: true,
|
||||
0x90: true,
|
||||
0x91: true,
|
||||
0x92: true,
|
||||
0x93: true,
|
||||
0x94: true,
|
||||
0x95: true,
|
||||
0x96: true,
|
||||
0x97: true,
|
||||
0x98: true,
|
||||
0x99: true,
|
||||
0x9a: true,
|
||||
0x9b: true,
|
||||
0x9c: true,
|
||||
0x9d: true,
|
||||
0x9e: true,
|
||||
0x9f: true,
|
||||
0xa0: true,
|
||||
0xa1: true,
|
||||
0xa2: true,
|
||||
0xa3: true,
|
||||
0xa4: true,
|
||||
0xa5: true,
|
||||
0xa6: true,
|
||||
0xa7: true,
|
||||
0xa8: true,
|
||||
0xa9: true,
|
||||
0xaa: true,
|
||||
0xab: true,
|
||||
0xac: true,
|
||||
0xad: true,
|
||||
0xae: true,
|
||||
0xaf: true,
|
||||
0xb0: true,
|
||||
0xb1: true,
|
||||
0xb2: true,
|
||||
0xb3: true,
|
||||
0xb4: true,
|
||||
0xb5: true,
|
||||
0xb6: true,
|
||||
0xb7: true,
|
||||
0xb8: true,
|
||||
0xb9: true,
|
||||
0xba: true,
|
||||
0xbb: true,
|
||||
0xbc: true,
|
||||
0xbd: true,
|
||||
0xbe: true,
|
||||
0xbf: true,
|
||||
0xc0: true,
|
||||
0xc1: true,
|
||||
0xc2: true,
|
||||
0xc3: true,
|
||||
0xc4: true,
|
||||
0xc5: true,
|
||||
0xc6: true,
|
||||
0xc7: true,
|
||||
0xc8: true,
|
||||
0xc9: true,
|
||||
0xca: true,
|
||||
0xcb: true,
|
||||
0xcc: true,
|
||||
0xcd: true,
|
||||
0xce: true,
|
||||
0xcf: true,
|
||||
0xd0: true,
|
||||
0xd1: true,
|
||||
0xd2: true,
|
||||
0xd3: true,
|
||||
0xd4: true,
|
||||
0xd5: true,
|
||||
0xd6: true,
|
||||
0xd7: true,
|
||||
0xd8: true,
|
||||
0xd9: true,
|
||||
0xda: true,
|
||||
0xdb: true,
|
||||
0xdc: true,
|
||||
0xdd: true,
|
||||
0xde: true,
|
||||
0xdf: true,
|
||||
0xe0: true,
|
||||
0xe1: true,
|
||||
0xe2: true,
|
||||
0xe3: true,
|
||||
0xe4: true,
|
||||
0xe5: true,
|
||||
0xe6: true,
|
||||
0xe7: true,
|
||||
0xe8: true,
|
||||
0xe9: true,
|
||||
0xea: true,
|
||||
0xeb: true,
|
||||
0xec: true,
|
||||
0xed: true,
|
||||
0xee: true,
|
||||
0xef: true,
|
||||
0xf0: true,
|
||||
0xf1: true,
|
||||
0xf2: true,
|
||||
0xf3: true,
|
||||
0xf4: true,
|
||||
0xf5: true,
|
||||
0xf6: true,
|
||||
0xf7: true,
|
||||
0xf8: true,
|
||||
0xf9: true,
|
||||
0xfa: true,
|
||||
0xfb: true,
|
||||
0xfc: true,
|
||||
0xfd: true,
|
||||
0xfe: true,
|
||||
0xff: true,
|
||||
}
|
||||
var (
|
||||
needEscapeHTMLNormalizeUTF8 *[256]bool
|
||||
needEscapeNormalizeUTF8 *[256]bool
|
||||
needEscapeHTML *[256]bool
|
||||
needEscape *[256]bool
|
||||
initStringTableOnce sync.Once
|
||||
)
|
||||
|
||||
var needEscapeHTML = [256]bool{
|
||||
'"': true,
|
||||
'&': true,
|
||||
'<': true,
|
||||
'>': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0xff */
|
||||
}
|
||||
func initStringTable() {
|
||||
initStringTableOnce.Do(func() {
|
||||
needEscapeHTMLNormalizeUTF8 = &[256]bool{
|
||||
'"': true,
|
||||
'&': true,
|
||||
'<': true,
|
||||
'>': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0x7f */
|
||||
0x80: true,
|
||||
0x81: true,
|
||||
0x82: true,
|
||||
0x83: true,
|
||||
0x84: true,
|
||||
0x85: true,
|
||||
0x86: true,
|
||||
0x87: true,
|
||||
0x88: true,
|
||||
0x89: true,
|
||||
0x8a: true,
|
||||
0x8b: true,
|
||||
0x8c: true,
|
||||
0x8d: true,
|
||||
0x8e: true,
|
||||
0x8f: true,
|
||||
0x90: true,
|
||||
0x91: true,
|
||||
0x92: true,
|
||||
0x93: true,
|
||||
0x94: true,
|
||||
0x95: true,
|
||||
0x96: true,
|
||||
0x97: true,
|
||||
0x98: true,
|
||||
0x99: true,
|
||||
0x9a: true,
|
||||
0x9b: true,
|
||||
0x9c: true,
|
||||
0x9d: true,
|
||||
0x9e: true,
|
||||
0x9f: true,
|
||||
0xa0: true,
|
||||
0xa1: true,
|
||||
0xa2: true,
|
||||
0xa3: true,
|
||||
0xa4: true,
|
||||
0xa5: true,
|
||||
0xa6: true,
|
||||
0xa7: true,
|
||||
0xa8: true,
|
||||
0xa9: true,
|
||||
0xaa: true,
|
||||
0xab: true,
|
||||
0xac: true,
|
||||
0xad: true,
|
||||
0xae: true,
|
||||
0xaf: true,
|
||||
0xb0: true,
|
||||
0xb1: true,
|
||||
0xb2: true,
|
||||
0xb3: true,
|
||||
0xb4: true,
|
||||
0xb5: true,
|
||||
0xb6: true,
|
||||
0xb7: true,
|
||||
0xb8: true,
|
||||
0xb9: true,
|
||||
0xba: true,
|
||||
0xbb: true,
|
||||
0xbc: true,
|
||||
0xbd: true,
|
||||
0xbe: true,
|
||||
0xbf: true,
|
||||
0xc0: true,
|
||||
0xc1: true,
|
||||
0xc2: true,
|
||||
0xc3: true,
|
||||
0xc4: true,
|
||||
0xc5: true,
|
||||
0xc6: true,
|
||||
0xc7: true,
|
||||
0xc8: true,
|
||||
0xc9: true,
|
||||
0xca: true,
|
||||
0xcb: true,
|
||||
0xcc: true,
|
||||
0xcd: true,
|
||||
0xce: true,
|
||||
0xcf: true,
|
||||
0xd0: true,
|
||||
0xd1: true,
|
||||
0xd2: true,
|
||||
0xd3: true,
|
||||
0xd4: true,
|
||||
0xd5: true,
|
||||
0xd6: true,
|
||||
0xd7: true,
|
||||
0xd8: true,
|
||||
0xd9: true,
|
||||
0xda: true,
|
||||
0xdb: true,
|
||||
0xdc: true,
|
||||
0xdd: true,
|
||||
0xde: true,
|
||||
0xdf: true,
|
||||
0xe0: true,
|
||||
0xe1: true,
|
||||
0xe2: true,
|
||||
0xe3: true,
|
||||
0xe4: true,
|
||||
0xe5: true,
|
||||
0xe6: true,
|
||||
0xe7: true,
|
||||
0xe8: true,
|
||||
0xe9: true,
|
||||
0xea: true,
|
||||
0xeb: true,
|
||||
0xec: true,
|
||||
0xed: true,
|
||||
0xee: true,
|
||||
0xef: true,
|
||||
0xf0: true,
|
||||
0xf1: true,
|
||||
0xf2: true,
|
||||
0xf3: true,
|
||||
0xf4: true,
|
||||
0xf5: true,
|
||||
0xf6: true,
|
||||
0xf7: true,
|
||||
0xf8: true,
|
||||
0xf9: true,
|
||||
0xfa: true,
|
||||
0xfb: true,
|
||||
0xfc: true,
|
||||
0xfd: true,
|
||||
0xfe: true,
|
||||
0xff: true,
|
||||
}
|
||||
|
||||
var needEscape = [256]bool{
|
||||
'"': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0xff */
|
||||
needEscapeNormalizeUTF8 = &[256]bool{
|
||||
'"': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0x7f */
|
||||
0x80: true,
|
||||
0x81: true,
|
||||
0x82: true,
|
||||
0x83: true,
|
||||
0x84: true,
|
||||
0x85: true,
|
||||
0x86: true,
|
||||
0x87: true,
|
||||
0x88: true,
|
||||
0x89: true,
|
||||
0x8a: true,
|
||||
0x8b: true,
|
||||
0x8c: true,
|
||||
0x8d: true,
|
||||
0x8e: true,
|
||||
0x8f: true,
|
||||
0x90: true,
|
||||
0x91: true,
|
||||
0x92: true,
|
||||
0x93: true,
|
||||
0x94: true,
|
||||
0x95: true,
|
||||
0x96: true,
|
||||
0x97: true,
|
||||
0x98: true,
|
||||
0x99: true,
|
||||
0x9a: true,
|
||||
0x9b: true,
|
||||
0x9c: true,
|
||||
0x9d: true,
|
||||
0x9e: true,
|
||||
0x9f: true,
|
||||
0xa0: true,
|
||||
0xa1: true,
|
||||
0xa2: true,
|
||||
0xa3: true,
|
||||
0xa4: true,
|
||||
0xa5: true,
|
||||
0xa6: true,
|
||||
0xa7: true,
|
||||
0xa8: true,
|
||||
0xa9: true,
|
||||
0xaa: true,
|
||||
0xab: true,
|
||||
0xac: true,
|
||||
0xad: true,
|
||||
0xae: true,
|
||||
0xaf: true,
|
||||
0xb0: true,
|
||||
0xb1: true,
|
||||
0xb2: true,
|
||||
0xb3: true,
|
||||
0xb4: true,
|
||||
0xb5: true,
|
||||
0xb6: true,
|
||||
0xb7: true,
|
||||
0xb8: true,
|
||||
0xb9: true,
|
||||
0xba: true,
|
||||
0xbb: true,
|
||||
0xbc: true,
|
||||
0xbd: true,
|
||||
0xbe: true,
|
||||
0xbf: true,
|
||||
0xc0: true,
|
||||
0xc1: true,
|
||||
0xc2: true,
|
||||
0xc3: true,
|
||||
0xc4: true,
|
||||
0xc5: true,
|
||||
0xc6: true,
|
||||
0xc7: true,
|
||||
0xc8: true,
|
||||
0xc9: true,
|
||||
0xca: true,
|
||||
0xcb: true,
|
||||
0xcc: true,
|
||||
0xcd: true,
|
||||
0xce: true,
|
||||
0xcf: true,
|
||||
0xd0: true,
|
||||
0xd1: true,
|
||||
0xd2: true,
|
||||
0xd3: true,
|
||||
0xd4: true,
|
||||
0xd5: true,
|
||||
0xd6: true,
|
||||
0xd7: true,
|
||||
0xd8: true,
|
||||
0xd9: true,
|
||||
0xda: true,
|
||||
0xdb: true,
|
||||
0xdc: true,
|
||||
0xdd: true,
|
||||
0xde: true,
|
||||
0xdf: true,
|
||||
0xe0: true,
|
||||
0xe1: true,
|
||||
0xe2: true,
|
||||
0xe3: true,
|
||||
0xe4: true,
|
||||
0xe5: true,
|
||||
0xe6: true,
|
||||
0xe7: true,
|
||||
0xe8: true,
|
||||
0xe9: true,
|
||||
0xea: true,
|
||||
0xeb: true,
|
||||
0xec: true,
|
||||
0xed: true,
|
||||
0xee: true,
|
||||
0xef: true,
|
||||
0xf0: true,
|
||||
0xf1: true,
|
||||
0xf2: true,
|
||||
0xf3: true,
|
||||
0xf4: true,
|
||||
0xf5: true,
|
||||
0xf6: true,
|
||||
0xf7: true,
|
||||
0xf8: true,
|
||||
0xf9: true,
|
||||
0xfa: true,
|
||||
0xfb: true,
|
||||
0xfc: true,
|
||||
0xfd: true,
|
||||
0xfe: true,
|
||||
0xff: true,
|
||||
}
|
||||
|
||||
needEscapeHTML = &[256]bool{
|
||||
'"': true,
|
||||
'&': true,
|
||||
'<': true,
|
||||
'>': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0xff */
|
||||
}
|
||||
|
||||
needEscape = &[256]bool{
|
||||
'"': true,
|
||||
'\\': true,
|
||||
0x00: true,
|
||||
0x01: true,
|
||||
0x02: true,
|
||||
0x03: true,
|
||||
0x04: true,
|
||||
0x05: true,
|
||||
0x06: true,
|
||||
0x07: true,
|
||||
0x08: true,
|
||||
0x09: true,
|
||||
0x0a: true,
|
||||
0x0b: true,
|
||||
0x0c: true,
|
||||
0x0d: true,
|
||||
0x0e: true,
|
||||
0x0f: true,
|
||||
0x10: true,
|
||||
0x11: true,
|
||||
0x12: true,
|
||||
0x13: true,
|
||||
0x14: true,
|
||||
0x15: true,
|
||||
0x16: true,
|
||||
0x17: true,
|
||||
0x18: true,
|
||||
0x19: true,
|
||||
0x1a: true,
|
||||
0x1b: true,
|
||||
0x1c: true,
|
||||
0x1d: true,
|
||||
0x1e: true,
|
||||
0x1f: true,
|
||||
/* 0x20 - 0xff */
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue