This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: empty function optimizations
- To: Joe Buck <jbuck at racerx dot synopsys dot com>, gcc at gcc dot gnu dot org
- Subject: Re: empty function optimizations
- From: Thomas Kunert <kunert at physik dot tu-dresden dot de>
- Date: Wed, 12 Jul 2000 08:46:34 +0200
- References: <200007112321.QAA21470@racerx.synopsys.com>
Joe Buck wrote:
>
> > Factoring might be a fair solution for the Linux folks' empty functions.
> > That was Geert's original proposal. Unfortunately the source of my problem
> > is mostly C++ templates. I don't have control to factor out the common
> > code. Well, sure I could have control but then that is like saying "don't
> > use templates".
>
> No, this is not true. The technique you need to use is called partial
> specialization. A typical use is, say, if you have Container<T>, but
> you can use the same code for any case where T is a pointer, or T is
> a PODS (plain old data structure).
>
> See Chapter 13.5 of Stroustrup's "The C++ Programming Language, 3rd
> Edition" for a good tutorial on how to use this technique.
>
> Ideally, the STL we provide should use a lot more partial specialization;
> for example
>
IMHO, that's the wrong approach. It's better to have an optimization in
the compiler than to uglify the code. And the code gets ugly if you do
that. Why should I do what the compiler could do for me?
Regards,
Thomas