Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: cwalsh AT nf DOT sympatico DOT ca (Colin Walsh), djgpp AT delorie DOT com Date: Tue, 23 Jun 1998 16:29:21 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Speed of class access.... In-reply-to: <358fdb1d.0@204.101.95.15> Precedence: bulk cwalsh AT nf DOT sympatico DOT ca (Colin Walsh) wrote: > I'm writing a 3D engine using DJGPP and I'm currently at the stage > where I could use some optimizations, and I've always heard that > C++ classes were slow in some way, and I happen to be using classes > for storing my 3D objects (meshes, triangles, texturemaps). > So, would it be in my best interests just to write some C helper > functions for managing these objects, or is the speed drop > negligible? Here is my experience: C++ classes are C structures with some special features. So if isn't slower than using structures. Virtual members can be slow because is like using pointers to functions inside an structure. Another important thing is that ALL the normal members receive an extra parameter (this) but if your C equivalent needs a pointer to the structure that's the same case. I personally think that the only bad things of C++ can be: 1) A buggy C++ front end with less optimization power than the C compiler. Eli says he have code that shows it, I never saw it. 2) The fact that C++ hides some task and hence the people is biased to do more complex things. (2) seems to be the worst. Looks like if people see only few lines in the code gets the impression that it will be faster and the reverse. So is common to see very unoptimized C++ source. Additionally gcc is a little bit idiot and using complex code the optimizer works very bad. Recomendation: Use C++ but EVER have in mind what code generates each C++ feature. SET ------------------------------------ 0 -------------------------------- Visit my home page: http://set-soft.home.ml.org/ or http://www.geocities.com/SiliconValley/Vista/6552/ Salvador Eduardo Tropea (SET). (Electronics Engineer) Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org ICQ: 2951574 Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013