Re: [Dev-C++] #DEFINE versus cont variables in array inicializations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <or...@vp...> - 2003-05-29 21:10:02
|
Per Westermark wrote: > I guess you don't think of gcc as a decent compiler then. An interesting thing I found, when examining g++ deeply: GCC is so smart, it even optimizes everything possible. Suppose you have a function, that returns a class. The normal behaviour would be: call copy constructor, return copied object. BUT if the variable was a local variable (created in the function) and you return that, then the "theoretical" behaviour would still be: copy object, return copied object, delete local variable, BUT gcc makes it very different: it simply return the local object without any copy, etc. It is not harmful, as the object would have been deleted anyway, so it is truly easier to simply return the local variable one-in-one. It is faster for sure. It truly does this, as I stated - I have checked the pointer for the object, and it is the same in the function, and the after return. Interesting... -- Greetings, Balázs |