Article 6PGR9 strlcpy and How CPUs Can Defy Common Sense

strlcpy and How CPUs Can Defy Common Sense

by
hubie
from SoylentNews on (#6PGR9)

owl writes:

https://nrk.neocities.org/articles/cpu-vs-common-sense

Recently one of my older post about strlcpy has sparked some discussion on various forums. Presumably the recently released POSIX edition had something to do with it. One particular counter-argument was raised by multiple posters - and it's an argument that I've heard before as well:

In the common case where the source string fits in to the destination buffer, strlcpy would only traverse the string once whereas strlen + memcpy would traverse it twice always.

Hidden in this argument is the assumption that traversing the string once is faster. Which - to be clear - is not at all an unreasonable assumption. But is it actually true? That's the focus of today's article.

Original Submission

Read more of this story at SoylentNews.

External Content
Source RSS or Atom Feed
Feed Location https://soylentnews.org/index.rss
Feed Title SoylentNews
Feed Link https://soylentnews.org/
Feed Copyright Copyright 2014, SoylentNews
Reply 0 comments