plans vis-a-vis inline functions and templates

Dirk Mueller dmuell at gmx.net
Tue Dec 16 18:49:47 CET 2003


On Tuesday 16 December 2003 17:05, Darin Adler wrote:

> > I also regularly inline short methods to reduce code bloat.
> Here's what I've learned from the many past C++ projects I worked on:
> If the methods are truly trivial, this will work. If they are not, then
> this attempt to reduce code bloat will actually make the code both
> larger and slower. It's difficult to tell the difference just by
> looking at the source code.

Hmm, well, I do read the assembler output from time to time. 

short inline methods is something like

  bool gimme() const { return memberfoo; }

or

   void setdude(bool foo) { memberfoo = foo; }

We had quite a lot of those in older versions of our tree (if you compare our 
css/ subdir with the one from the webcore release you'll notice). 

Also another nice case of inlining is trivial constructors or destructors (the 
destructors can even be removed alltogether). 

Another candidate are methods that are only called in one single place. there 
is (most of the time) not a good reason to keep them separate, especially if 
the separate implementation is not even inline (I've seen a couple of such 
additions in the Webcore tree). 

When it comes to reducing debug symbols, then all those 

bool itispossiblyeitherFooOrMaybeBar() const { return itsfoo() || itsbar(); }

could be removed again. the actual implementation is also easier readable to 
me  than the WordSConcatenationStyle :)

Just some random ideas with IMHO of course. 


Dirk


More information about the Khtml-devel mailing list