3. General Recommendations
- Rec. 1
- Optimize code only if you know
that you have a performance problem. Think twice before you begin.
- Rec. 2
- If you use a C++ compiler that is
based on Cfront, always compile with the +w flag set to eliminate as
many warnings as possible.
Various tests are said to have demonstrated that programmers generally
spend a lot of time optimizing code that is never executed. If your
program is too slow, use gprof++ or an equivalent tool to
determine the exact nature of the problem before beginning to optimize.
Code that is accepted by a compiler is not always correct (in
accordance with the definition of the C++ language). Two reasons for this
are that changes are made in the language and that compilers may contain
bugs. In the short term, very little can be done about the latter.
In order to reduce the amount of code that must be rewritten for each
new compiler release, it is common to let the compiler provide warnings
instead of reporting errors for such code until the next major release.
Cfront provides the +w flag to direct the compiler to give warnings for
these types of language changes.