lundi 2 mars 2015

Is using a getter in a for-each loop inefficient?

Recently I have been doing the following in my code:



for(auto& item : something.getSomeVector())


As I started my optimization pass, I started to wonder if that is less efficient than something like the following:



std::vector<Type> vTypes = something.getSomeVector();
for(auto& item : vTypes)


Would a for-each loop copy the vector or just keep calling that function?


Thanks!


Aucun commentaire:

Enregistrer un commentaire