From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: djgpp/rhide acting strange Date: Tue, 27 Jan 1998 18:08:55 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 33 Message-ID: <34CE6907.B70@cs.com> References: <199801272138 DOT KAA03406 AT cirrostratus DOT netaccess DOT co DOT nz> NNTP-Posting-Host: ppp242.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Richard Chappell wrote: > > What does optimization do?? Does it make your exe file smaller, or > faster, or what?? Yes, yes, and yes. :-) Optimization allows the compiler to figure out ways to make code run faster. This almost always results in size savings as well. The exact details of what the compiler does to optimize your code are complex; I suggest you look in the gcc documentation to find out all the potential benefits. Some basic optimizations include: - Putting frequently used variables into registers to reduce the time required for memory access. - Using "shortcuts" to make arithmetic calculations run faster (shifts instead of multiplies with powers of 2, for instance). - Changing around the order of conditional and looping statements to make more frequently used code come first. - Implementing branching structures like switch() statements as lookup tables instead of a series of tests. - Eliminating code that has no apparent purpose. - Inlining functions. There's lots more. -- --------------------------------------------------------------------- | John M. Aldrich | "To be 'matter of fact' about the | | aka Fighteer I | world is to blunder into fantasy-- | | mailto:fighteer AT cs DOT com | and dull fantasy at that, as the real| | http://www.cs.com/fighteer | world is strange and wonderful." -LL | ---------------------------------------------------------------------