Posted Nov 25, 2010 3:47 UTC (Thu) by iabervon (subscriber, #722)
Parent article: On breaking things
On the memcpy thing, I have to wonder whether it wouldn't be pretty much optimal on modern processors to implement both memcpy and memmove as the same, using a pair of implementations, each of which works for a different direction of overlap, and either just comparing the pointers to see which way the potential overlap is. If one direction is really substantially faster, you could also check whether there's any overlap and always use that one if there isn't.
That is, I expect that libraries are full of calls to memmove where the library doesn't know that the buffers don't overlap, and so the performance of memmove on non-overlapping buffers matters; and probably a few tests on things in registers aren't going to be noticeable next to a loop and memory accesses.