From 4f833da24e37de0c33f2b68df06a1d1d165f54f9 Mon Sep 17 00:00:00 2001 From: cokicm Date: Mon, 3 Jun 2024 17:21:29 +0200 Subject: [PATCH] Optimized opMLoad to avoid unnecessary allocations. --- state/runtime/evm/instructions.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/state/runtime/evm/instructions.go b/state/runtime/evm/instructions.go index c66ba052e4..0b156c7b6f 100644 --- a/state/runtime/evm/instructions.go +++ b/state/runtime/evm/instructions.go @@ -356,15 +356,14 @@ func opSar(c *state) { func opMLoad(c *state) { v := c.top() - var ok bool - c.tmp, ok = c.get2(c.tmp[:0], *v, *wordSize256) - - // ### Error handling? - if !ok { + if !c.allocateMemory(*v, *wordSize256) { return } - v.SetBytes(c.tmp) + offset := v.Uint64() + size := wordSize256.Uint64() + + v.SetBytes(c.memory[offset : offset+size]) } func opMStore(c *state) {