pmartz / jag-3d

Automatically exported from code.google.com/p/jag-3d
0 stars 1 forks source link

Pass shared_ptr by reference #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To date, much of Jag has been coded by passes shared_ptr variables as 
parameters, rather than references to shared_ptrs. An example would be 
jagSG::Node::addChild:
    void addChild( NodePtr node );
which should be:
    void addChild( NodePtr& node );

Passing by reference avoids an unnecessary invocation of the shared_ptr copy 
constructor and is therefore more efficient.

This change should be made universally throughout the existing Jag code base, 
and references should be used (as a general rule) moving forward.

Need to check: Will a reference work in the base class case? For example, 
imagine class B derives from class A. Will this code work?
  void myFunc( shared_ptr<A>& aParam );
  shared_ptr<B> bVar;
  myFunc( bVar );
That is, can we use:
    void myFunc( shared_ptr<A>& aParam );
or do we have to use:
    void myFunc( shared_ptr<A> aParam );
Need to test and make sure the reference will work OK.

Original issue reported on code.google.com by SkewMat...@gmail.com on 19 Jul 2013 at 6:12

GoogleCodeExporter commented 9 years ago
This work has been done for the most part.

Original comment by SkewMat...@gmail.com on 31 Oct 2013 at 8:03