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
}
if uint64(len(m.store)) > offset {
// memory is always resized before being accessed, no need to check bounds
cpy = make([]byte, size)
copy(cpy, m.store[offset:offset+size])
}
return
}
@ -85,13 +83,10 @@ func (m *Memory) GetPtr(offset, size uint64) []byte {
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 nil
}
// Len returns the length of the backing slice
func (m *Memory) Len() int {
return len(m.store)