Optimzed vs. readable code

Jonathan Wakely jwakely.gcc@gmail.com
Wed Nov 30 17:18:00 GMT 2005


On 11/29/05, Pierre THIERRY <nowhere.man@levallois.eu.org> wrote:
> > And while you are  probably correct that an optimizer will result in
> > identical object  code for changes like this, such a change is adding
> > to the complexity  of the overall product (library + compiler).
>
> The question could be: do you know any compiler yet, used widely enough
> that it is important for libstdc++ to actively support it, that won't do
> that tiny optimization?

Yes -- GCC at -O0
 
> If not, I couldn't see any other argument against that change, and there
> are arguments in favor of it...

here are some more ...
If the change was to be accepted, should it be a new iterator object or just a reference to give the existing object a new name?  Will the right choice still be the right choice in a year, when GCC's optimisers are different?  Or in five years?  Who will keep measuring it to ensure the code is still optimal?

Your suggestion will probably never result in *better* code, so the best we can hope for is equal performance, but possibly worse if a regression occurs in the compiler.

The primary use of the library code is not to be read by end users, it's to execute efficiently and correctly. It is executed many more times than it is read.

There are *far* harder things to understand in the code than a variable name that is misleading the first few times you see it  :-)

jon



More information about the Libstdc++ mailing list