forked from TrueCloudLab/neoneo-go
compiler: optimize append argument processing
Append should leave it's result on top of the stack. Thus we need to transform top of the stack: (top) a . b --> (top) a . b . b It can be done with just OVER + SWAP.
This commit is contained in:
parent
b6629fb6bd
commit
7053b3b2c0
1 changed files with 1 additions and 3 deletions
|
@ -744,10 +744,8 @@ func (c *codegen) convertBuiltin(expr *ast.CallExpr) {
|
||||||
if isByteArrayType(typ) {
|
if isByteArrayType(typ) {
|
||||||
emitOpcode(c.prog.BinWriter, opcode.CAT)
|
emitOpcode(c.prog.BinWriter, opcode.CAT)
|
||||||
} else {
|
} else {
|
||||||
|
emitOpcode(c.prog.BinWriter, opcode.OVER)
|
||||||
emitOpcode(c.prog.BinWriter, opcode.SWAP)
|
emitOpcode(c.prog.BinWriter, opcode.SWAP)
|
||||||
emitOpcode(c.prog.BinWriter, opcode.DUP)
|
|
||||||
emitOpcode(c.prog.BinWriter, opcode.PUSH2)
|
|
||||||
emitOpcode(c.prog.BinWriter, opcode.XSWAP)
|
|
||||||
emitOpcode(c.prog.BinWriter, opcode.APPEND)
|
emitOpcode(c.prog.BinWriter, opcode.APPEND)
|
||||||
}
|
}
|
||||||
case "panic":
|
case "panic":
|
||||||
|
|
Loading…
Reference in a new issue