help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inheritance - why so slow?


From: Krzysztof Duleba
Subject: Re: Inheritance - why so slow?
Date: Fri, 8 Oct 2004 12:14:29 +0200

Paul Pluzhnikov wrote:

> > Nobody else finds this interesting?
>
> No, not really.
>
> Draw inheritance tree for the code you are generating (just do it
> for N=3), and count how many classes A3 inherits from (directly
> and indirectly). The compiler has to search them all.
>
> Since that number grows exponentially (2**N - 1),

Tell me if I'm wrong, but there are only N classes, right? So the graph
has only O(N) veticles and O(N^2) edges. Where can you see a tree of
exponential size?

> why are you surprized that you see an exponential slow-down?

I'd expect O(N^2) slow-down and Visual C++ seems to work his fast. Why
should g++ be that much slower?

Regards
Krzysztof Duleba






reply via email to

[Prev in Thread] Current Thread [Next in Thread]