From 1847c28b421851b695c4e00394c08f34fa1f1f1d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 19 Jun 2020 17:37:07 +0300 Subject: [PATCH] compiler: do not load values which will be dropped --- pkg/compiler/codegen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index 44f26dae9..c126449c4 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -924,7 +924,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { emit.Opcode(c.prog.BinWriter, opcode.OVER) emit.Jmp(c.prog.BinWriter, opcode.JMPLEL, end) - if n.Key != nil { + if n.Key != nil && n.Key.(*ast.Ident).Name != "_" { if isMap { c.rangeLoadKey() } else { @@ -932,7 +932,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { } c.emitStoreVar(n.Key.(*ast.Ident).Name) } - if n.Value != nil { + if n.Value != nil && n.Value.(*ast.Ident).Name != "_" { c.rangeLoadKey() if isMap { // we have loaded only key from key array, now load value