compiler: optimize argument reversing

Do not reverse arguments if there is no more than 1.
This commit is contained in:
Evgenii Stratonikov 2020-06-19 17:28:07 +03:00
parent 3729865860
commit 72be5412f4

View file

@ -1011,6 +1011,7 @@ func (c *codegen) dropItems(n int) {
// emitReverse reverses top num items of the stack. // emitReverse reverses top num items of the stack.
func (c *codegen) emitReverse(num int) { func (c *codegen) emitReverse(num int) {
switch num { switch num {
case 0, 1:
case 2: case 2:
emit.Opcode(c.prog.BinWriter, opcode.SWAP) emit.Opcode(c.prog.BinWriter, opcode.SWAP)
case 3: case 3: