forked from TrueCloudLab/neoneo-go
vm: do not copy parameter
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
a5516e8c96
commit
f5d1277bfd
1 changed files with 4 additions and 5 deletions
|
@ -97,9 +97,9 @@ func (c *Context) NextIP() int {
|
||||||
return c.nextip
|
return c.nextip
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next returns the next instruction to execute with its parameter if any. After
|
// Next returns the next instruction to execute with its parameter if any.
|
||||||
// its invocation the instruction pointer points to the instruction being
|
// The parameter is not copied and shouldn't be written to. After its invocation
|
||||||
// returned.
|
// the instruction pointer points to the instruction being returned.
|
||||||
func (c *Context) Next() (opcode.Opcode, []byte, error) {
|
func (c *Context) Next() (opcode.Opcode, []byte, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -171,8 +171,7 @@ func (c *Context) Next() (opcode.Opcode, []byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return instr, nil, err
|
return instr, nil, err
|
||||||
}
|
}
|
||||||
parameter := make([]byte, numtoread)
|
parameter := c.prog[c.nextip : c.nextip+numtoread]
|
||||||
copy(parameter, c.prog[c.nextip:c.nextip+numtoread])
|
|
||||||
c.nextip += numtoread
|
c.nextip += numtoread
|
||||||
return instr, parameter, nil
|
return instr, parameter, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue