| Issue 4: | [Coding] Useless argument copies. |
‹ Prev
4 of 4
|
| 1 person starred this issue and may be notified of changes. | Back to list |
In the new code (but certainly everywhere), you are passing the argument by value (so a copy is done), for your fonction. Example: Background(string textureName). When calling this function, the string will be copied and this can slow your program. To avoid the copy, you should use references: Background(const string& textureName); And so, just a pointer will be copied. The const guaranties (and protects) the textureName from changes (so it will result like it has been copied, but it's not really). And the use of the reference is exactly the same than normal variables. For additional details, you should look in a C++ tutorial or book ;)
May 1, 2011
Project Member
#1
lionel.r...@gmail.com
May 1, 2011
All the string argument for constructors added in r22 are missing at least.
May 7, 2011
Done :)
May 16, 2011
The problem is back: Drawable::Drawable(const string& textureName, Coord<float> position) (For position) Ok, it's a minor one.
May 17, 2011
I correct it and some others. Thanks for your help ;) |