My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 4: [Coding] Useless argument copies.
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by lw.demos...@googlemail.com, May 1, 2011
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
I put many references in arguments but I forgot someones maybe.
I look Bjarn Stroustrup's book and many tutorials on the net ;)
May 1, 2011
#2 lw.demos...@googlemail.com
All the string argument for constructors added in r22 are missing at least.
May 7, 2011
Project Member #3 lionel.r...@gmail.com
Done :)
May 16, 2011
#4 lw.demos...@googlemail.com
The problem is back:

Drawable::Drawable(const string& textureName, Coord<float> position)

(For position)
Ok, it's a minor one.


May 17, 2011
Project Member #5 lionel.r...@gmail.com
I correct it and some others. Thanks for your help ;)

Powered by Google Project Hosting