Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Q: Performance for public vs protected data in C++ (OT)

Author: Gerd Isenberg

Date: 03:27:09 10/21/02

Go up one level in this thread


On October 18, 2002 at 15:34:12, Bo Persson wrote:

>On October 18, 2002 at 09:11:30, Gerd Isenberg wrote:
>
>>On October 17, 2002 at 19:29:30, Peter Fendrich wrote:
>>
>>>Is there any reason why 'protected' data should have better performance than
>>>'public'? What could the compier do with this extra information?
>>>Peter
>>
>>Hi Peter,
>>
>>access qualification has no impact on performance. Another thing are 'const'
>>functions. The information that a function does not change anything inside this
>>object permits the compiler to do additional optimizations, eg. holding data
>>members in registers.
>>
>>Gerd
>
>No!
>
>The compiler can see for itself whether you change the data or not. If you
>declare a member function const and then try to change the object anyway, the
>compiler complains. Because it can tell!
>
>
>
>
>Bo Persson
>bop2@telia.com


from AMD Athlon™ Processor x86 Code Optimization Guide:
Chapter 3 C Source-Level Optimizations

Use Const Type Qualifier
Use the “const” type qualifier as much as possible. This
optimization makes code more robust and may enable higher
performance code to be generated due to the additional
information available to the compiler. For example, the C
standard allows compilers to not allocate storage for objects
that are declared “const” if their address is never taken.

Gerd



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.