Skip to content

Commit

Permalink
core/vm: optimize Memory.Set32 (ethereum#24847)
Browse files Browse the repository at this point in the history
* core/vm: remove unnecessary memset for Memory.Set32

* core/vm: optimize Memory.Set32
  • Loading branch information
qianbin authored and gzliudan committed Mar 1, 2024
1 parent 62b62da commit 032b98e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/vm/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ func (m *Memory) Set32(offset uint64, val *uint256.Int) {
if offset+32 > uint64(len(m.store)) {
panic("invalid memory: store empty")
}
// Zero the memory area
copy(m.store[offset:offset+32], []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
// Fill in relevant bits
val.WriteToSlice(m.store[offset:])
b32 := val.Bytes32()
copy(m.store[offset:], b32[:])
}

// Resize resizes the memory to size
Expand Down

0 comments on commit 032b98e

Please sign in to comment.