PATCH: reduce strlen() calls

Mark Mitchell mark@codesourcery.com
Mon Jul 29 09:41:00 GMT 2002


> I think, that's what `write_string` macro is doing. But if a string size
> is fixed, why run strlen() to measure it?

1. It makes it easy to get the right answer.

2. It makes the code more robust -- you do not have to remember to change
   the number.

3. It is not any slower; GCC will optimize away the call to strlen anyhow.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the Gcc-patches mailing list