3 ms·
Thank you for the reply. I did think about the significance of the length of the string, but I was too lazy to benchmark that. Perhaps another time. Theoretical
by johnisgood 7y ago
Thank you for the reply. I did think about the significance of the length of the string, but I was too lazy to benchmark that. Perhaps another time. Theoretically, for the reasons you mentioned, memccpy should perform better on larger strings, but I am not sure if that really is the case in practice (slow implementation of memccpy, lack of compiler optimizations, etc.), and it seems like that "stick to memccpy" is not an universal rule (obviously). :D
- eMSF 7y agoNote that I mentioned the ordinary memcpy (with a single c) there briefly. memccpy should under no circumstances be faster than strcpy for "string multiplying", as it holds no advantages over it in that use.
- johnisgood 7y agoOuch, my mistake. In any case, could we sum it up? In what cases should memccpy be used over, say, str{n,l}cpy, or even memcpy, and is it in conflict with the article's recommendation or its statement on performance regarding memccpy vs. the alternatives?