forked from mirror/go-json
Merge pull request #88 from goccy/feature/fix-optype
Reduce code size of encode_optype.go
This commit is contained in:
commit
8b3bc49833
|
@ -99,6 +99,12 @@ const (
|
||||||
{{- end }}
|
{{- end }}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var opTypeStrings = [{{ .OpLen }}]string{
|
||||||
|
{{- range $type := .OpTypes }}
|
||||||
|
"{{ $type.Op }}",
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
type opType int
|
type opType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -108,14 +114,11 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t opType) String() string {
|
func (t opType) String() string {
|
||||||
switch t {
|
if int(t) >= {{ .OpLen }} {
|
||||||
{{- range $type := .OpTypes }}
|
|
||||||
case op{{ $type.Op }}:
|
|
||||||
return "{{ $type.Op }}"
|
|
||||||
{{- end }}
|
|
||||||
}
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
return opTypeStrings[int(t)]
|
||||||
|
}
|
||||||
|
|
||||||
func (t opType) codeType() codeType {
|
func (t opType) codeType() codeType {
|
||||||
if strings.Contains(t.String(), "Struct") {
|
if strings.Contains(t.String(), "Struct") {
|
||||||
|
|
8321
encode_optype.go
8321
encode_optype.go
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue