The key difference between memcpy()
and memmove()
is that memmove()
will work fine when source and destination overlap. When buffers surely don't overlap memcpy() is preferable since it's potentially faster.
What bothers me is this potentially. Is it a microoptimization or are there real significant examples when memcpy()
is faster so that we really need to use memcpy()
and not stick to memmove()
everywhere?
At best, calling memcpy
rather than memmove
will save a pointer comparison and a conditional branch. For a large copy, this is completely insignificant. If you are doing many small copies, then it might be worth measuring the difference; that is the only way you can tell whether it's significant or not.
It is definitely a microoptimisation, but that doesn't mean you shouldn't use memcpy
when you can easily prove that it is safe. Premature pessimisation is the root of much evil.