From be02eea7b159ca22637d2ea7a833c6d72b0064af Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 9 Nov 2022 12:33:20 +0300 Subject: [PATCH] binding: precompile template, remove useless error condition --- pkg/smartcontract/binding/generate.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/smartcontract/binding/generate.go b/pkg/smartcontract/binding/generate.go index b3a735917..e2f3aeb66 100644 --- a/pkg/smartcontract/binding/generate.go +++ b/pkg/smartcontract/binding/generate.go @@ -79,6 +79,8 @@ type ( } ) +var srcTemplate = template.Must(template.New("generate").Parse(srcTmpl)) + // NewConfig initializes and returns a new config instance. func NewConfig() Config { return Config{ @@ -97,12 +99,7 @@ func Generate(cfg Config) error { ctr.Imports = append(ctr.Imports, "github.com/nspcc-dev/neo-go/pkg/interop/neogointernal") sort.Strings(ctr.Imports) - tmp, err := template.New("generate").Parse(srcTmpl) - if err != nil { - return err - } - - return tmp.Execute(cfg.Output, ctr) + return srcTemplate.Execute(cfg.Output, ctr) } func scTypeToGo(name string, typ smartcontract.ParamType, overrides map[string]Override) (string, string) {