Const Function Parameters?

Joseph Garvin k04jg02 at kzoo.edu
Thu Jul 28 17:06:03 CDT 2005


Has anyone checked if the performance improvement stays if only the
pointers are set to const?

I'd also suggest running the test multiple times and averaging.

Felix Nawothnig wrote:

> Andreas Mohr wrote:
>
>> While I'm not too convinced in this case (1.5% improvement sounds like
>> within statistic noise), it should be a good idea to mark things in Wine
>> const whenever possible (objdump -x helps here), since it improves 
>> reliability
>
>
> Huh? He did stuff like...
>
> -void foo(int i)
> +void foo(const int i)
>
> This will most likely not improve reliability. He also changed some 
> pointers to const which is wanted and will ofcourse improve reliability.
>
> Assuming that gcc has a pretty good optimizer the only reason I can 
> think of (besides a GCC bug :-) why performance increased is that gcc 
> doesn't have to perform aliasing-analysis and can be sure that the dst 
> pointer will never point into local parameters (constifying local 
> variables could speed up things slightly more).
>
> I'm not sure about the "restrict" semantics but maybe it could be used 
> instead of constifying "int i" to archieve the same effects?
>
> Felix
>





More information about the wine-devel mailing list