KDE/kdevelop/languages/cpp
David Nolden
david.nolden.kdevelop at art-master.de
Wed Oct 31 16:10:19 UTC 2007
On Wednesday 31 October 2007 16:22:50 Andreas Pakulat wrote:
> SVN commit 731382 by apaku:
>
> Fix the build, while doing that I noticed that somehow there seem to be two
> API's. One uses "real" pointers to DUContext and other duchain stuff and
> quite some other functions/classes use the shared pointer stuff.
>
> Now you can call me insane but that makes this stuff quite more
> complicated, can't we just always use the shared pointers in the language
> parts?
The DUChainPointer things are only needed when storing pointers across duchain
lock/unlock cycles, because whenever the duchain is unlocked, any duchain
item may be deleted between the unlock and the next access to the item.
For operations while the duchain is locked, DUChainPointers are not needed.
They add an additional level of indirection which isn't good
performance-wise, and are a bit more complicated to handle than normal
pointers(For example normal pointers can automatically be casted to
base-classes etc.), need an additional include-file, and I think normal
pointers simply look "cleaner" when more complex things are not needed.
So the general rule is: Always use DUChainPointer when you store the pointers
for longer time or across lock/unlock cycles, and use normal pointers when
doing temporary operations within a single lock cycle(like most
TypeConversion stuff etc.)
Personally I don't like using the slower variant always, after all we're not
java, and must take some performance profit from that ;)
greetings, David
More information about the KDevelop-devel
mailing list