Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!grace.cs.washington.edu!jeffb From: jeffb@grace.cs.washington.edu (Jeff Bowden) Newsgroups: comp.lang.c++ Subject: Having constructors is expensive. Summary: cfront 1.2 is stoooopid. Message-ID: Date: 31 May 89 07:29:05 GMT Sender: news@beaver.cs.washington.edu Distribution: comp Organization: Thorn of Taxis Lines: 23 I'm writing a C++ program for which I really care about performance. I'm using cfront 1.2. I recently profiled my program using gprof only to find that 82% of my program execution time was being spent in a no-argument, EMPTY CONSTRUCTOR. Needless to say, I was slightly annoyed. I find constructors are very useful and I wish I could use them, but this is just too much. The problem (which I found by examining the output of CC -F) is that the empty constructor (which is defined in the class declaration, so it is should to be inline) somehow gets incarnated and called as a normal function! This wouldn't be so bad except that I declare many arrays of vectors of this class and I generally use only 10% of the elements. (I have an empty constructor because of the vectors; fascist cfront doesn't like it when you declare vectors of things which haven't any no-argument constructor). My current solution consists eliminating the constructors for this class and using some overloaded `friend' functions in place of the constructors (e.g. class foo { /*...*/ friend foo mkfoo(); /*...*/ }; ). This leads to a vast improvement in performance, but it's damn ugly. Anyone have a better suggestion/fix????? -- "How well do you really know the back of your hand?"