-
The stored reference would be a
usize
; the offset could be much shorter. This could be significant if the offset wasu8
oru16
and theusize
wasu128
. -
A physical move of the object in memory or a
clone
would justmemcpy
the offset, whereas extra code would need to be emitted immediately after thememcpy
to relocate the reference before the relocated object was available for use. -
The reference could be used as is, whereas relocation code would need to be emitted each time the offset needed to be converted (de-relativized?) to a reference, and the inverse offset-computation code would need to be emitted each time an object self-reference needed to be converted to and stored as an offset.
2 Likes