empty function optimizations
Joe Buck
jbuck@racerx.synopsys.com
Tue Jul 11 13:17:00 GMT 2000
> This came up on the Linux kernel list yesterday, but I have been thinking
> about this for a long time. In our C++ project, we use container templates
> fairly heavily. The problem is that often the templates generate function
> code that is independent of the class, or maybe only dependent on the class
> sizeof. With hundreds of classes it really adds up.
I would recommend explicitly factoring out the common code. Partial
specialization can be your friend here.
> Would collecting all the identical code at link time be as easy as it
> sounds, or are there complications?
Some conforming programs would break, but these are fairly obscure (e.g.
programs that compare function pointers). Debugging might get harder.
But if you factor out common code, you can get greater savings than the
compiler can find and your gains are portable.
More information about the Gcc
mailing list