[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: dynamic_cast performance overhead
From: Michael Buesch <mbuesch () freenet ! de>
Date: 2005-06-02 18:18:39
Message-ID: 200506022018.39948.mbuesch () freenet ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
Quoting Sunil <funtoos@yahoo.com>:
> Hi,
>
> First email in this forum and new to kde code, so
> please excuse me if I am off the mark.
>
> I have noticed that dynamic_cast can add a LOT of
> overhead to the runtime execution, particularly on
> platforms where g++ doesn't do a good job. So, I
> started a little exercise to figure out if there were
> places in KDE code where it wasn't needed but was
> present.
Hi, did you profile some code? I (and I'm pretty sure
others, too) am interrested in numbers on how
much slower it is, in which cases, on which compiler.
I often use dynamic_cast, even if a reinterpret_cast
would do just fine.
I already thought about this in the past (without
thinking that it may be a major performance problem).
I thought about something like this to cast pointers:
#ifdef DEBUG
# define save_reinterpret_cast(type, p) \
({
if (dynamic_cast< type >(p) == 0)
print_error_and_quit_app;
reinterpret_cast< type >(p)
})
#else
# define save_reinterpret_cast(type, p) reinterpret_cast< type >(p)
#endif
This is not tested, may be implemented in a better
way, but I think you know what I mean.
Maybe a template function or something similiar would be better.
--
Greetings, Michael
[Attachment #5 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic