[cfe-dev] Proposed C++ optimization with big speed gains with big objects

Ladislav Nevery neuralll at gmail.com
Wed Sep 26 15:51:57 PDT 2012


Actually the sample you provided will work without problem. 
Since switch works only on first assign(after default constructor) 

TextFile textfile[1000]; // default constructor doing nothing

textfile[1]=TextFile("c:\test1.txt"); // = we call destructor doing nothing
and placement new
textfile[1]=TextFile("c:\test1.txt"); // standard temp copy + operator combo

But I see the point if you put code logic to default constructor then yes
first assign will not happen. You use switch to remove copy from arrays
init. So yes actual code change is needed in this statistically marginal
case.

Anyway code logic (opening files etc) in default constructors is BLASPHEMY !
:D such people actually deserve to being punished.
Punishing them a bit more is actually good thing ;D Lets call it feature




--
View this message in context: http://clang-developers.42468.n3.nabble.com/Proposed-C-optimization-with-big-speed-gains-with-big-objects-tp4026886p4026968.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list