forked from TrueCloudLab/neoneo-go
vm: improve REVERSEITEMS for 1M Buffer
Before: BenchmarkOpcodes/REVERSEITEMS/buffer/1M-8 1680 758747 ns/op After: BenchmarkOpcodes/REVERSEITEMS/buffer/1M-8 2649 442720 ns/op
This commit is contained in:
parent
bdd073aad7
commit
bf9ecc2bd3
1 changed files with 2 additions and 1 deletions
|
@ -1132,8 +1132,9 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
|||
a[i], a[j] = a[j], a[i]
|
||||
}
|
||||
case *stackitem.Buffer:
|
||||
slice := t.Value().([]byte)
|
||||
for i, j := 0, t.Len()-1; i < j; i, j = i+1, j-1 {
|
||||
t.Value().([]byte)[i], t.Value().([]byte)[j] = t.Value().([]byte)[j], t.Value().([]byte)[i]
|
||||
slice[i], slice[j] = slice[j], slice[i]
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid item type %s", t))
|
||||
|
|
Loading…
Reference in a new issue