Skip to content

Commit

Permalink
Don't allocate for zero length bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Dec 12, 2024
1 parent 0afaf50 commit e2c4dc2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arbos/programs/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,16 @@ func addressToBytes20(addr common.Address) bytes20 {
}

func (slice *rustSlice) read() []byte {
if slice.len == 0 {
return nil
}
return arbutil.PointerToSlice((*byte)(slice.ptr), int(slice.len))
}

func (vec *rustBytes) read() []byte {
if vec.len == 0 {
return nil
}
return arbutil.PointerToSlice((*byte)(vec.ptr), int(vec.len))
}

Expand Down

0 comments on commit e2c4dc2

Please sign in to comment.