mercredi 12 juillet 2017

c++ performance based on object creation

I work with legacy C++ that was originally written to compile with C++98. But, we compile now with C++11 (yay!) and try to use the newer compiler features when putting in new or modifying old code. This is a common thing seen in our code:

MyObj a = doCalc(); // some calculation result
MyObj b = a; // copy a to b before modifying a

My question is this. If I change the above to take advantage of newer object creation techniques, am I making the code perform better? Is there any difference to the compiler? Like this:

MyObj a(b); // is this better for performance?

Aucun commentaire:

Enregistrer un commentaire