drop wrong and not-required bound check

This commit is contained in:
lmittmann 2024-08-06 14:44:44 +02:00
parent 0ddfe7a9d1
commit 0265e9b6c0

View file

@ -71,11 +71,9 @@ func (m *Memory) GetCopy(offset, size uint64) (cpy []byte) {
return nil return nil
} }
if uint64(len(m.store)) > offset { // memory is always resized before being accessed, no need to check bounds
cpy = make([]byte, size) cpy = make([]byte, size)
copy(cpy, m.store[offset:offset+size]) copy(cpy, m.store[offset:offset+size])
}
return return
} }
@ -85,11 +83,8 @@ func (m *Memory) GetPtr(offset, size uint64) []byte {
return nil return nil
} }
if uint64(len(m.store)) > offset { // memory is always resized before being accessed, no need to check bounds
return m.store[offset : offset+size] return m.store[offset : offset+size]
}
return nil
} }
// Len returns the length of the backing slice // Len returns the length of the backing slice