dcreager.net

“strlcpy and how CPUs can defy common sense”

2024-07-26

strlcpy and how CPUs can defy common sense [NRK]

A nice analysis of how scanning a string twice (strlen + memcpy) can be faster than scanning it once (strlcpy).

Also contains a link to a fun (possibly made up?) quote from Tony Hoare in a discussion with Nico Lomuto.

Computers do not have common sense. Computers are surprising.
–Tony Hoare [possibly?]

Lomuto's comeback [Andrei Alexandrescu]

» Languages » C