Merge pull request from goccy/feature/fix-optype

Reduce code size of encode_optype.go
This commit is contained in:
Masaaki Goshima 2021-01-17 22:40:40 +09:00 committed by GitHub
commit 8b3bc49833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2786 additions and 5550 deletions

View File

@ -99,6 +99,12 @@ const (
{{- end }}
)
var opTypeStrings = [{{ .OpLen }}]string{
{{- range $type := .OpTypes }}
"{{ $type.Op }}",
{{- end }}
}
type opType int
const (
@ -108,13 +114,10 @@ const (
)
func (t opType) String() string {
switch t {
{{- range $type := .OpTypes }}
case op{{ $type.Op }}:
return "{{ $type.Op }}"
{{- end }}
if int(t) >= {{ .OpLen }} {
return ""
}
return ""
return opTypeStrings[int(t)]
}
func (t opType) codeType() codeType {

File diff suppressed because it is too large Load Diff