With memcpy
, the destination cannot overlap the source at all. With memmove
it can. This means that memmove
might be very slightly slower than memcpy
, as it cannot make the same assumptions.
For example, memcpy
might always copy addresses from low to high. If the destination overlaps after the source, this means some addresses will be overwritten before copied. memmove
would detect this and copy in the other direction - from high to low - in this case. However, checking this and switching to another (possibly less efficient) algorithm takes time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…