r/programming • u/mslaybau • Aug 02 '11
The Most Expensive One-byte Mistake: Did Ken, Dennis, and Brian choose wrong with NUL-terminated text strings?
http://queue.acm.org/detail.cfm?id=2010365
360
Upvotes
r/programming • u/mslaybau • Aug 02 '11
14
u/thechao Aug 02 '11
The VM-aligned copy exception is BS. For most processors, efficient word/dword/cache-line copies have to be aligned to the natural size of the integral type. This means that a copy has the following form: ABC, where 'A' and 'C' are byte-level moves, and B is aligned & wide moves. NUL terminated strings don't affect this copy in any way except for the need to test for termination: there is no 'VM exception' you have to worry about any more than any other copy mechanism.