This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Comparative performance of C(gcc) and C++(g++)
- From: Mihnea Balta <dark_lkml at mymail dot ro>
- To: John Love-Jensen <eljay at adobe dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 30 Jan 2003 17:14:41 +0200
- Subject: Re: Comparative performance of C(gcc) and C++(g++)
- References: <BA5E9A01.7058%eljay@adobe.com>
On Thursday 30 January 2003 16:59, John Love-Jensen wrote:
> Hi Mihnea,
>
> >Making and using interfaces through the use of virtual functions forces
> > the
>
> compiler to generate extra code that looks up the method's address in the
> object's virtual table before actually calling the method. This can lead to
> performance issues.
>
> C++ often leads to performance improvements, because the common C way to do
> something similar is through a switch statement on a tag value, which is
> LESS efficient than the C++ virtual table lookup mechanism.
Yes, of course, but I was referring to misuse or overuse. I agree that if you
emulate the mechanism, you will almost surely get slower code than what the
compiler generates.