Two similar functions optimized differently

Jim Wilson wilson@specifixinc.com
Sat Jun 26 03:33:00 GMT 2004


Alfie wrote:
>   While playing with variations on a simple string comparing function,
> I discovered that gcc will inline tolower differently for what appear
> to be two almost identical functions.

gcc doesn't do any inlining of tolower.  tolower is a macro defined by 
glibc.

>   In the second (faster) function, gcc will compile the code to call
> __ctype_tolower_loc only once, which it then stores for later use.

You need to include <ctype.h> to get the __ctype_tolower_loc calls. 
This was left out of your example.

When I try this with mainline (3.5) sources I get the desired result, so 
it looks like this has already been fixed.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc mailing list