Of course you shouldn&#x27;t optimize unless it&#x27;s the biggest bottleneck and more performance (or battery life) is desired.<p>C string operations might have been elegant 40 years ago, but nowadays they&#x27;re like rerouting a 747 to check if office lights are on.<p>Strlen is doing a lot of work for little benefit. It does slow and power hungry memory accesses. Because it&#x27;s scanning for terminating 0x00 byte, it needs to contain a branch -- and loop terminating branch <i>must</i> be a costly mis-predicted one.<p>C printf and friends are even more insane. It scans &quot;bytecode&quot; instructions from a string and does dynamic formatting. You can do format options like this:<p><pre><code>  printf(&quot;% 0#*.*f\n&quot;, 15, 5, 1.234);
</code></pre>
Or say print five chars of an <i>unterminated string</i>, left padded to total length of 10:<p><pre><code>  printf(&quot;%10.5s\n&quot;, unterminated_str);
</code></pre>
It won&#x27;t (at least it shouldn&#x27;t) crash even if 6th character is on an unreadable memory page.