KDE/kdevelop/languages/cpp

Andreas Pakulat apaku at gmx.de
Wed Oct 31 16:37:06 UTC 2007


On Mittwoch, 31. Oktober 2007, David Nolden wrote:
> 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 ;)

Ok, I agree, but then there are two things that need to happen:

a) revert most of my changes as I almost always just created a temporary 
DUChainPointer
b) make the constructors of DUChainPointer implicit again, Hamish made 
them explicit and I don't really know why, but I didn't feel like 
changing that as there might have been a reason for that...

Andreas

-- 
Be cautious in your daily affairs.




More information about the KDevelop-devel mailing list