Re: const functions

From: Robert Collins <robert.collins@dont-contact.us>
Date: Tue, 23 Oct 2001 14:58:43 +1000

----- Original Message -----
From: "Alex Rousskov" <rousskov@measurement-factory.com>
>
> I can think of a few reasons to avoid the hack.
>
> 0. It has a double underscore

?

> 1. It looks ugly

Sure.

> 2. It is highly unlikely to provide any measurable performance
> improvement for Squid in the foreseeable future

Multiple function calls add up. Even with a good locality of reference.

> 3. The function that qualifies now may not qualify
> tomorrow, but the compiler will continue to
> over-optimize it, producing hard-to-find bugs

This is a good point. However, code maintenance is part of development.
So I'd counter this point by having a note in the function header
whenever the prototype has the attribute.

> 4. We may think that a function qualifies, but it
> does not (same side-effects as in 3)

I agree.

> 5. Technically, it is compiler's work to find these functions
> automatically.

This one I disagree with. The compiler is ignorant of functions in
different files - or even in libraries. If the compiler had information
from the previous invocations with which to work, then sure it could be
the compilers job. But for now I don't think any compiler will optimise
out (say) library calls - unless such a hint it provided to it.

(Mind you, library calls that have no side effects and only depend on
the arguments probably should be macros).

Rob
Received on Mon Oct 22 2001 - 22:55:22 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:34 MST