3 ms·
"2. Loop-invariant strlen() GCC does this optimization, because strlen is a "built-in function:" one that gcc recognizes and optimizes specially. Disabling bui
by grogers 16y ago
"2. Loop-invariant strlen()
GCC does this optimization, because strlen is a "built-in function:" one that gcc recognizes and optimizes specially. Disabling built-ins with -fno-builtin defeats this optimization."
No, it does it because strlen is declared to be a pure function, and it is smart enough to realize you are not modifying anything in s. -fno-builtin does not change the generated code, it still calls the strlen function (at least on my gcc), but it is hoisted out of the loop.