www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/28/09:59:25

Date: Mon, 28 Jul 1997 09:56:18 -0400 (EDT)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
To: Erik Max Francis <max AT alcyone DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: optimising
In-Reply-To: <33D593DC.16992348@alcyone.com>
Message-Id: <Pine.D-G.3.91.970728094943.19151A-100000@dg1>
Mime-Version: 1.0

On Tue, 22 Jul 1997, Erik Max Francis wrote:

> DrkWatr wrote:
> 
> > I was wondering if there is a program that will
> > optimisize your c source, and still let you view it as c source? Thus
> > allowing me to learn better programming habits.
> 
> Erik Max Francis wrote:
>
> I know of no such beast.  Optimization is generally done at the compiler
> level, not the source level.
> 
> Furthermore, such a beast would probably not be all _that_ much use.
> Optimization at the source level is highly dependent on the compiler and
> platform (for instance, the sizes of the fundamental types) that you're
> using.  Optimization is better left to the compiler, which 1. is
> generating the code in the first place, and 2. has a far better idea of
> the environment than any generalized program can.
 
I don't think that DrkWatr is looking for that kind of 'Optimization' but 
something that will help him to write better "C".  You know the kind of 
common wisdom that says:
	for(;;){} is better than while(1){}
	p=&ar[0]; .... p++ is better than i=0; ... ar[i++];
etc.  Sorry to have to agree that there is no such beasty.  He needs to 
get a good "C" book and then keep in mind that many of these 'common 
wisdom' optimizations are made unneccessary by a good optimizer such as 
GCC/DJGPP has.  Indeed in both of the examples I gave the code GCC 
generates is at least as good for the 'bad' code as for the 'good' code. 

Art S. Kagel, kagel AT bloomberg DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019