Path: utzoo!attcan!uunet!ogicse!decwrl!elroy.jpl.nasa.gov!usc!wuarchive!mit-eddie!apollo!williams_j From: williams_j@apollo.HP.COM (Jim Williams) Newsgroups: comp.lang.c++ Subject: Re: Request for C++ coding "guidelines" Keywords: C++, inlines Message-ID: <48ccd464.20b6d@apollo.HP.COM> Date: 22 Feb 90 18:25:00 GMT References: <4446@pegasus.ATT.COM> <4843@helios.ee.lbl.gov> <84@pascal.decvax.UUCP> Sender: root@apollo.HP.COM Lines: 17 This brings up an important reason for using inlines. The example class I have is too long to be included here, but it contains a number of member functions, all declared "inline", which perform numerical calculations. By expanding these inline, the C compiler optimizer is able to eliminate the majority of these calculations because the results are never used. A lot of the rest of the calculations can be done at ("C") compile time because the complier knows the value of the arguments passed to the functions. The performance increase therefore far exceeds the overhead of the function call and may be closer to an order of magnitude. If these functions were not "inlined", some of the performance could be gotten back by adding some record keeping to the class so that it could be determined at run time which values actually needed to be calculated. This would add complexity, however. Also, I don't see any way to force computations to be done at compile time for non-inlined functions. My vote is that if a function is declared "inline", it should either be implemented inline, or if not possible, flagged as an error.