Merge pull request #1526 from nspcc-dev/improve-worst-case-reverseitems

vm: improve REVERSEITEMS for 1M Buffer
This commit is contained in:
Roman Khimov 2020-11-07 23:18:34 +03:00 committed by GitHub
commit 58f384a323
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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] a[i], a[j] = a[j], a[i]
} }
case *stackitem.Buffer: case *stackitem.Buffer:
slice := t.Value().([]byte)
for i, j := 0, t.Len()-1; i < j; i, j = i+1, j-1 { 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: default:
panic(fmt.Sprintf("invalid item type %s", t)) panic(fmt.Sprintf("invalid item type %s", t))