4 ms·
>For the unfamiliar, memmove is a potentially slower variant of memcpy It's worth pointing out that the performance hit of memmove vs. memcpy is a single check
by mistercow 14y ago
>For the unfamiliar, memmove is a potentially slower variant of memcpy
It's worth pointing out that the performance hit of memmove vs. memcpy is a single check in memmove which decides, based on if the source or destination address is higher, whether to copy front to back or back to front. You're never going to win any measurable performance gains by replacing a memmove call with a memcpy.
- eridius 14y agoThat single check could potentially be a branch mis-predict.
- deleted 14y ago[deleted]
- mistercow 14y agoThe only time it would make a big difference would be if you were doing a lot of small memmoves in a tight loop. In that scenario, you mispredict at the end of the loop within memmove/memcpy anyway. So when the outer loop comes back around, the pipe is already empty and any mis-predict on the pointer comparison is basically harmless.