I see many places in code, where objects pass by value, when could pass through ref(&).
For example:
// MapForCreating.cpp : line 3
MapForCreating::MapForCreating(string tilesPlace, string backgroundPlace, string playerPlaceIn, string platformPlaceIn)
{
...
}
All of this strings we can pass, by constant ref, like that const string& str.
The fact is that when passing by value, objects are copied, passing objects by reference, copying does not occur, therefore the program runs faster.
Also, look at pass by std::string_view, but in this case I am not an expert and not sure it can work for all four strings.
This may not only be about strings.
I see many places in code, where objects pass by value, when could pass through ref(
&).For example:
All of this strings we can pass, by constant ref, like that
const string& str.The fact is that when passing by value, objects are copied, passing objects by reference, copying does not occur, therefore the program runs faster.
Also, look at pass by
std::string_view, but in this case I am not an expert and not sure it can work for all four strings.This may not only be about strings.