interop/contract: micro-optimize argument pushes

Calling Estack() again and again is not very productive.
This commit is contained in:
Roman Khimov 2021-11-19 16:26:01 +03:00
parent d1f4928e29
commit 8c704a49b5

View file

@ -115,8 +115,8 @@ func callExFromNative(ic *interop.Context, caller util.Uint160, cs *state.Contra
ic.VM.Invocations[cs.Hash]++
ic.VM.LoadScriptWithCallingHash(caller, cs.NEF.Script, cs.Hash, ic.VM.Context().GetCallFlags()&f, hasReturn, uint16(len(args)))
ic.VM.Context().NEF = &cs.NEF
for i := len(args) - 1; i >= 0; i-- {
ic.VM.Estack().PushItem(args[i])
for e, i := ic.VM.Estack(), len(args)-1; i >= 0; i-- {
e.PushItem(args[i])
}
// use Jump not Call here because context was loaded in LoadScript above.
ic.VM.Jump(ic.VM.Context(), md.Offset)