Skip to content

Commit e0a1fd5

Browse files
authored
core/vm: optimize Memory.Set32 (#24847)
* core/vm: remove unnecessary memset for Memory.Set32 * core/vm: optimize Memory.Set32
1 parent f5ff022 commit e0a1fd5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

core/vm/memory.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ func (m *Memory) Set32(offset uint64, val *uint256.Int) {
5353
if offset+32 > uint64(len(m.store)) {
5454
panic("invalid memory: store empty")
5555
}
56-
// Zero the memory area
57-
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})
5856
// Fill in relevant bits
59-
val.WriteToSlice(m.store[offset:])
57+
b32 := val.Bytes32()
58+
copy(m.store[offset:], b32[:])
6059
}
6160

6261
// Resize resizes the memory to size

0 commit comments

Comments
 (0)