2 ms·
> The tiny performance hit is usually worth the safety and simplicity It need not even be a performance hit. The compiler could recognize the idiom of code suc
by Someone 4y ago
> The tiny performance hit is usually worth the safety and simplicity
It need not even be a performance hit. The compiler could recognize the idiom of code such as
snprintf(buffer, bufLen, "%s%s%s", s, t, u);
and optimize it into (example possibly buggy; my C is rusty)
b = buffer;
e = b + bufLen:
while((b < e) && (*b++ = *s++));
while((b < e) && (*b++ = *t++));
while((b < e) && (*b++ = *u++));
*b = 0;